0.1.2 • Published 12 months ago

downpipe v0.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

Downpipe : Pipe Operator

Installation

Grab it from NPM:

npm i downpipe

Setting Up

To use downpipe, follow these steps:

  1. Import the Default class export from the package. This is your pipe constructor.
import Downpipe from 'downpipe'
  1. 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
  1. 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.
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.

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago