2018-11-22 16:41:46 +01:00
|
|
|
import { noop } from './noop';
|
|
|
|
export function pipe(...fns) {
|
|
|
|
return pipeFromArray(fns);
|
|
|
|
}
|
|
|
|
export function pipeFromArray(fns) {
|
|
|
|
if (!fns) {
|
|
|
|
return noop;
|
|
|
|
}
|
|
|
|
if (fns.length === 1) {
|
|
|
|
return fns[0];
|
|
|
|
}
|
|
|
|
return function piped(input) {
|
|
|
|
return fns.reduce((prev, fn) => fn(prev), input);
|
|
|
|
};
|
|
|
|
}
|
2019-06-04 14:29:48 +02:00
|
|
|
//# sourceMappingURL=pipe.js.map
|