Stone.js API
    Preparing search index...

    Function singleFlight

    • Run factory for key at most once at a time: concurrent calls share the in-flight promise, so a cold key is never computed twice under a burst (cache stampede / dogpile protection).

      Type Parameters

      • T

      Parameters

      • inflight: Map<string, Promise<any>>

        The shared in-flight map.

      • key: string

        The cache key.

      • factory: () => Promise<T>

        The value producer.

      Returns Promise<T>

      The produced value.