@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
20 lines (19 loc) • 601 B
JavaScript
/** Helper type for single arg function */
/**
* Compose 1 to n functions.
* @param func first function
* @param funcs additional functions
*/
export function compose(func) {
for (var _len = arguments.length, funcs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
funcs[_key - 1] = arguments[_key];
}
var allFuncs = [func].concat(funcs);
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return function composed(raw) {
return allFuncs.reduceRight(function (memo, func) {
return func(memo);
}, raw);
};
}