1.2.1 • Published 9 years ago

pied v1.2.1

Weekly downloads
1
License
ISC
Repository
github
Last release
9 years ago

npm.io

Why is it Awesome?

Install

npm install pied --save

Usage

import pipe from 'pied';

// -- Working with primitives

let double = x => x + x;
let square = x => x * x;

let val = pipe(5).to(double).to(square);

console.log( Number(val) ); // 100

// -- Working with non primitives

let dubs = x => x.concat(x);

let piped = pipe([1, 2]).to(dubs);

console.log( piped.length ); // 4

No Kicker

pipe(5).to(double) * 2; // 20

Accessing Values Between Pipes

let piped = pipe([1, 2]).to(dubs);

// accessing the array directly
piped.push(3);

console.log( piped.length ); // 5

// piping again
piped.to(dubs);

console.log( piped.length ); // 10

Note: This feature requires Proxy. If you do not have access to Proxy you can use pipe([1, 2]).to(dubs).valueOf() to access the inner array directly.