Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

pipe.js 646B

123456789101112131415161718192021222324
  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