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

    Class SyncResolveOnce<T, CTX>Internal

    Synchronous version of ResolveOnce for functions that return non-promise values.

    This class is used internally by ResolveOnce when it detects a synchronous function. It executes the function once and caches the result or error for subsequent calls.

    Type Parameters

    • T

      The return type

    • CTX = void

      Optional context type

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    queueLength: 0

    Accessors

    • get value(): T | undefined

      Gets the cached value if available.

      Returns T | undefined

    • get error(): Error | undefined

      Gets the cached error if one occurred.

      Returns Error | undefined

    • get ready(): boolean

      Returns true if the function has been executed.

      Returns boolean

    Methods

    • Executes the function once and caches the result. Subsequent calls return the cached value without re-executing.

      Parameters

      • fn: (ctx?: CTX) => T

        The function to execute

      Returns T

      The result of the function

      Error if the function returned a promise (use AsyncResolveOnce instead)

    • Resets the cached state, allowing the function to be executed again.

      Parameters

      • Optionalfn: (c?: CTX) => T

        Optional function to execute immediately after reset

      Returns T | undefined

      The result if fn provided, undefined otherwise