rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
23 lines • 895 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fpRunWithin = void 0;
const _debug_js_1 = require("../../debug/_debug.js");
/**
* @public
* Runs the `callback` within the `wrapperFunctions`. This is useful for "positional" attributes, like debug labels, lifecycle block scopes etc.
* @remarks
* See {@link fpRunWithin}.
*/
function fpRunWithin(wrapperFunctions, callback) {
_BUILD.DEBUG && _debug_js_1._Debug.assert(wrapperFunctions.length > 0, "there must be at least one wrapper function");
return (...args) => {
let chained = () => callback(...args);
for (let i = 0, iEnd = wrapperFunctions.length; i < iEnd; ++i) {
const prev = chained;
chained = () => wrapperFunctions[i](prev);
}
return chained();
};
}
exports.fpRunWithin = fpRunWithin;
//# sourceMappingURL=fp-run-within.js.map