Skip to content

Commit 75d4d08

Browse files
committed
Add implementation for large pipes
1 parent 31d71e8 commit 75d4d08

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/utils.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
}
44
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
55
switch (arguments.length) {
6+
case 0:
7+
return id;
68
case 1:
79
return ab;
810
case 2:
@@ -37,8 +39,12 @@
3739
return function () {
3840
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
3941
};
42+
default:
43+
const init_val = ab.apply(this, arguments);
44+
return function () {
45+
return Array.from(arguments).slice(1).reduce((acc, f) => f(acc), init_val);
46+
}
4047
}
41-
return;
4248
}
4349
function pipe(
4450
a,
@@ -62,7 +68,9 @@
6268
rs,
6369
st
6470
) {
65-
switch (arguments.length) {
71+
switch (arguments.length) {
72+
case 0:
73+
return;
6674
case 1:
6775
return a;
6876
case 2:
@@ -111,8 +119,9 @@
111119
qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))
112120
)
113121
);
122+
default:
123+
return Array.from(arguments).reduce((acc, f) => f(acc));
114124
}
115-
return;
116125
}
117126

118127
const makeMultishotGeneratorDo = (of) => (chain) => (generatorFun) => {

0 commit comments

Comments
 (0)