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.
19 lines • 742 B
JavaScript
import { _Debug } from "../../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}.
*/
export function fpRunWithin(wrapperFunctions, callback) {
_BUILD.DEBUG && _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();
};
}
//# sourceMappingURL=fp-run-within.js.map