diff --git a/snippets/pipe.md b/snippets/pipe.md new file mode 100644 index 000000000..16f3e59d6 --- /dev/null +++ b/snippets/pipe.md @@ -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==" +```