14 lines
339 B
JavaScript
Raw Normal View History

2021-02-11 21:31:41 +08:00
"use strict";
/**
* Build functional pipeline.
*/
module.exports = function compose(...processors) {
if (processors.length === 0)
return (input) => input;
if (processors.length === 1)
return processors[0];
return processors.reduce((prev, next) => {
return (...args) => next(prev(...args));
});
};