Skip to main content

Function: createSingleFlight()

function createSingleFlight<Args, Result>(
fn: (...args: Args) => Promisable<Result>
): (...args: Args) => Promise<Result>;

Defined in: shared/utils/singleFlight.ts:26

Wrap an async function so that only one invocation runs at a time. Concurrent calls return the in-flight promise.

Type Parametersโ€‹

Argsโ€‹

Args extends readonly unknown[]

Resultโ€‹

Result

Parametersโ€‹

fnโ€‹

(...args: Args) => Promisable<Result>

Returnsโ€‹

(...args: Args) => Promise<Result>