Pipe example
This commit is contained in:
8
snippets/pipe.md
Normal file
8
snippets/pipe.md
Normal 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=="
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user