Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
390 bytes
|
Line | |
---|
1 | import { identity } from './identity';
|
---|
2 | export function pipe(...fns) {
|
---|
3 | return pipeFromArray(fns);
|
---|
4 | }
|
---|
5 | export function pipeFromArray(fns) {
|
---|
6 | if (fns.length === 0) {
|
---|
7 | return identity;
|
---|
8 | }
|
---|
9 | if (fns.length === 1) {
|
---|
10 | return fns[0];
|
---|
11 | }
|
---|
12 | return function piped(input) {
|
---|
13 | return fns.reduce((prev, fn) => fn(prev), input);
|
---|
14 | };
|
---|
15 | }
|
---|
16 | //# sourceMappingURL=pipe.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.