downpipe
v0.1.2
Published
pipe operator, it goes down
Downloads
1
Readme
Downpipe : Pipe Operator
Installation
Grab it from NPM:
npm i downpipe
Setting Up
To use downpipe, follow these steps:
- Import the
Default
class 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
Downpipe
and feel free to destructure thev
function. 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: 947135
License
This project is licensed under the MIT License.