Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
646 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | var identity_1 = require("./identity");
|
---|
| 4 | function pipe() {
|
---|
| 5 | var fns = [];
|
---|
| 6 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
| 7 | fns[_i] = arguments[_i];
|
---|
| 8 | }
|
---|
| 9 | return pipeFromArray(fns);
|
---|
| 10 | }
|
---|
| 11 | exports.pipe = pipe;
|
---|
| 12 | function pipeFromArray(fns) {
|
---|
| 13 | if (fns.length === 0) {
|
---|
| 14 | return identity_1.identity;
|
---|
| 15 | }
|
---|
| 16 | if (fns.length === 1) {
|
---|
| 17 | return fns[0];
|
---|
| 18 | }
|
---|
| 19 | return function piped(input) {
|
---|
| 20 | return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
---|
| 21 | };
|
---|
| 22 | }
|
---|
| 23 | exports.pipeFromArray = pipeFromArray;
|
---|
| 24 | //# sourceMappingURL=pipe.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.