import type { Fn, Fn2, Fn3, Fn4, IObjectOf, MaybePromise, NumOrString } from "@thi.ng/api"; /** * The most minimalistic memoization function of this package, but only supports * numbers or strings as arguments (max. 4) and uses a vanilla JS object as * cache. * * @remarks * If `fn` throws an error, no result value will be cached and no memoization * happens for this invocation using the given arguments. * * Use {@link memoizeAsyncO} for async functions or other functions returning * promises. * * @example * ```ts tangle:../export/memoizeo.ts * import { memoizeO } from "@thi.ng/memoize"; * * const test = memoizeO((x: number) => (console.log("exec", x), x * 10)); * * console.log(test(1)); * // exec 1 * // 10 * * console.log(test(1)) * // 10 * * console.log(test(2)); * // exec 2 * // 20 * ``` * * @param fn * @param cache */ export declare function memoizeO(fn: Fn, cache?: IObjectOf): Fn; export declare function memoizeO(fn: Fn2, cache?: IObjectOf): Fn2; export declare function memoizeO(fn: Fn3, cache?: IObjectOf): Fn3; export declare function memoizeO(fn: Fn4, cache?: IObjectOf): Fn4; /** * Async version of {@link memoizeO}. * * @remarks * If `fn` throws an error, no result value will be cached and no memoization * happens for this invocation using the given arguments. * * @param fn * @param cache */ export declare function memoizeAsyncO(fn: Fn>, cache?: IObjectOf): Fn>; export declare function memoizeAsyncO(fn: Fn2>, cache?: IObjectOf): Fn2>; export declare function memoizeAsyncO(fn: Fn3>, cache?: IObjectOf): Fn3>; export declare function memoizeAsyncO(fn: Fn4>, cache?: IObjectOf): Fn4>; //# sourceMappingURL=memoizeo.d.ts.map