pipe.js 565 B

123456789101112131415161718192021
  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