Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jisaacks/pied-piper
https://github.com/jisaacks/pied-piper
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jisaacks/pied-piper
- Owner: jisaacks
- Created: 2015-12-01T15:51:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-01T19:22:51.000Z (almost 9 years ago)
- Last Synced: 2024-09-16T09:40:40.067Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![](./pied.jpg)
Why is it Awesome?
* [Doesn't require a kicker](#no-kicker)
* [Can be treated as a raw value between pipes](#accessing-values-between-pipes)### Install
```shell
npm install pied --save
```### Usage
``` javascript
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
```javascript
pipe(5).to(double) * 2; // 20
```### Accessing Values Between Pipes
```javascript
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). If you do not have access to Proxy you can use `pipe([1, 2]).to(dubs).valueOf()` to access the inner array directly.