14 lines
339 B
JavaScript
14 lines
339 B
JavaScript
"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));
|
|
});
|
|
};
|