@dodiameer/pipe-js

1.0.1 • Public • Published

PipeJS

Simple pipe function, takes return value of a function and passes it as the first argument to the next function.

Features

  • Supports async functions
  • Works everywhere (browser, NodeJS)
  • No dependencies

Installation

Install PipeJS with npm

npm install @dodiameer/pipe-js

Install PipeJS with pnpm

pnpm install @dodiameer/pipe-js

Install PipeJS with yarn

yarn add @dodiameer/pipe-js

Usage

import { pipe } from "@dodiameer/pipe-js" // or `import pipe from "@dodiameer/pipe-js"`

const value = await pipe(
    getDataFromApi,
    serializeData,
    // To pass arguments, write an array with the function
    // as the first item and the rest of the arguments
    [prettyPrint, { tabWidth: 2 }]
)

// Above is equivalent to this
const data = await getDataFromApi()
const serializedData = serializeData(data)
const value =  prettyPrint(serializedData, { tabWidth: 2 })

Practical example

See this CodePen

Package Sidebar

Install

npm i @dodiameer/pipe-js

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

3.04 kB

Total Files

4

Last publish

Collaborators

  • dodiameer