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:
565 bytes
|
Line | |
---|
1 | /** PURE_IMPORTS_START _identity PURE_IMPORTS_END */
|
---|
2 | import { identity } from './identity';
|
---|
3 | export function pipe() {
|
---|
4 | var fns = [];
|
---|
5 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
6 | fns[_i] = arguments[_i];
|
---|
7 | }
|
---|
8 | return pipeFromArray(fns);
|
---|
9 | }
|
---|
10 | export function pipeFromArray(fns) {
|
---|
11 | if (fns.length === 0) {
|
---|
12 | return identity;
|
---|
13 | }
|
---|
14 | if (fns.length === 1) {
|
---|
15 | return fns[0];
|
---|
16 | }
|
---|
17 | return function piped(input) {
|
---|
18 | return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
---|
19 | };
|
---|
20 | }
|
---|
21 | //# sourceMappingURL=pipe.js.map
|
---|
Note:
See
TracBrowser
for help on using the repository browser.