pipe operator, it goes down
npm install downpipeGrab it from NPM:
``shell`
npm i downpipe
To use downpipe, follow these steps:
1. Import the Default class export from the package. This is your pipe constructor.
`js`
import Downpipe from 'downpipe'
2. 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.
`js`
const double = (n) => n * 2
const increment = (n) => n + 1
3. Create a new instance of Downpipe and feel free to destructure the v function. Pass an object with your functions in as the sole argument.
`js`
const { v } = new Downpipe({ double, increment })
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.
`js`
const someNumber = 473566;
const pipedNumber =
v(someNumber)
.double
.increment
.increment
.increment
.return;
`js``
console.log(pipedNumber); // Outputs: 947135
This project is licensed under the MIT License.