UNPKG

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 419 B
/** * @public * Creates a function that can be called many times but will run at most once. * * @remarks * See {@link fpOnce}. */ export function fpOnce(initialize) { let item; let initialized = false; return (...args) => { if (initialized) { return item; } initialized = true; return item = initialize(...args); }; } //# sourceMappingURL=fp-once.js.map