Pipe example

This commit is contained in:
conblem
2017-12-12 17:01:01 +01:00
parent 4594d060ed
commit f7d2695866

8
snippets/pipe.md Normal file
View File

@ -0,0 +1,8 @@
### Pipe
Use `reduce()` to pass value through functions.
```js
const pipe = (...funcs) => arg => funcs.reduce((acc, func) => func(acc), arg);
// pipe(btoa, x => x.toUpperCase())("Test") -> "VGVZDA=="
```