downpipe
v0.1.2
Published
pipe operator, it goes down
Readme
Downpipe : Pipe Operator
Installation
Grab it from NPM:
npm i downpipeSetting Up
To use downpipe, follow these steps:
- Import the
Defaultclass export from the package. This is your pipe constructor.
import Downpipe from 'downpipe'- Have your single-argument functions ready. You get type hinting, but no enforced type safety between pipe functions, so create your pipe class instances responsibly.
const double = (n) => n * 2
const increment = (n) => n + 1- Create a new instance of
Downpipeand feel free to destructure thevfunction. Pass an object with your functions in as the sole argument.
const { v } = new Downpipe({ double, increment })Piping
Don't invoke the functions themselves, just invoke v to pass the starting value in and then chain your functions. Make sure to end it with a return.
const someNumber = 473566;
const pipedNumber =
v(someNumber)
.double
.increment
.increment
.increment
.return;console.log(pipedNumber); // Outputs: 947135License
This project is licensed under the MIT License.
