pipe-it-down
v1.0.0
Published
Simplify your code by chaining functions through pipes
Downloads
3
Maintainers
Readme
pipe-it-down
Extremely barebones implementation of pipes, inspired by Elixir.
To use it, simply kick off a chain, optionally supplying an initial value.
If no initial value, it will default to null.
Example:
Javascript:
// node import
const { chain } = require('pipe-it-down');
// es6-style import
import { chain } from 'pipe-it-down';
const totalDataset = chain(dataset)
.pipe( normalize )
.pipe( assignWeights(weights) )
.pipe( average )
.end();
Which would be equivalent to typing out:
const totalDataset = average(assignWeights(weights)(normalize(dataset)))
or somewhat cleaner:
const normalized = normalize(dataset);
const weighted = assignWeights(weights)(normalized);
const totalDataset = average(weighted);
Note:
If operating over arrays, this is very similar to map/filter/reduce combinations.