@adviser/cement - v0.0.0
    Preparing search index...

    Interface ResolveOnceOpts

    Ensures a function is executed only once, caching and returning the result for subsequent calls.

    ResolveOnce automatically detects whether the function returns a synchronous value or a Promise, and handles both cases appropriately. All subsequent calls will receive the same cached result. Supports optional context parameter and can be reset to allow re-execution.

    The return type of the function (can be synchronous or Promise)

    Optional context type passed to the function

    const expensiveOp = new ResolveOnce<number>();

    // First call executes the function
    const result1 = expensiveOp.once(() => computeExpensiveValue());

    // Subsequent calls return cached result
    const result2 = expensiveOp.once(() => computeExpensiveValue()); // Not executed

    // Reset to allow re-execution
    expensiveOp.reset();
    interface ResolveOnceOpts {
        resetAfter?: number;
        skipUnref?: boolean;
    }
    Index

    Properties

    resetAfter?: number
    skipUnref?: boolean