UNPKG
fn-pipe
Version:
latest (1.0.2)
1.0.2
1.0.1
1.0.0
Pipe function for function composition
github.com/ZAKdev/fn-pipe
ZAKdev/fn-pipe
fn-pipe
/
pipe.js
8 lines
•
184 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
export
const
pipe
= (
...fns
) =>
data
=>
fns.
reduce
(
(
acc, fn
) =>
{
if
(
typeof
acc.
then
===
'function'
){
return
acc.
then
(fn) }
else
{
return
fn
(acc) } }, data)