soundcloud-api-ts - v1.13.4
    Preparing search index...

    Class InFlightDeduper

    Deduplicates concurrent in-flight requests with the same key.

    When multiple callers request the same resource simultaneously, only one underlying promise is created — all callers share the result. The key is cleaned up automatically once the promise settles.

    const deduper = new InFlightDeduper();

    // Both calls share a single fetch:
    const [a, b] = await Promise.all([
    deduper.add('track:123', () => fetchTrack(123)),
    deduper.add('track:123', () => fetchTrack(123)),
    ]);
    // a === b (same resolved value)
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    Methods

    • Return an existing in-flight promise for key, or start a new one via factory. The entry is removed from the map once the promise settles (resolve or reject).

      Type Parameters

      • T

      Parameters

      • key: string
      • factory: () => Promise<T>

      Returns Promise<T>