@lacunahub/letsfrag
    Preparing search index...

    Class PromiseManager

    Manages pending promises for request-response patterns using nonce-based correlation. Allows creating promises that can be resolved/rejected externally by their nonce identifier.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    cache: WishMap<string, CachedPromise> = ...

    Cache of pending promises keyed by nonce

    Methods

    • Creates a new promise and stores it in cache for later resolution

      Type Parameters

      • T

        The expected type of the resolved value

      Parameters

      • nonce: string

        The unique identifier for the promise

      • options: { timeout?: number } = {}

        Creation options

        • Optionaltimeout?: number

          Timeout in milliseconds after which the promise auto-rejects

      Returns Promise<T>

      A promise that will be resolved/rejected when resolve/reject is called with the same nonce

    • Checks if a promise with the given nonce exists

      Parameters

      • nonce: string

        The unique identifier for the promise

      Returns boolean

      True if the promise exists in cache

    • Rejects a pending promise by its nonce and removes it from cache

      Parameters

      • nonce: string

        The unique identifier for the promise

      • error: Error | MakeErrorOptions

        The error to reject the promise with

      Returns void

    • Resolves a pending promise by its nonce and removes it from cache

      Parameters

      • nonce: string

        The unique identifier for the promise

      • Optionalvalue: unknown

        The value to resolve the promise with

      Returns void