Enode — API Reference
    Preparing search index...

    Function createSingleFlight

    • Wraps a handler so re-entrant calls are dropped while a previous invocation is in flight.

      Type Parameters

      • Args extends unknown[]
      • R

      Parameters

      • handler: (...args: Args) => R

        The guarded function. May return a promise (async gate) or any other value (sync gate with trailing lockout only).

      • Optionaloptions: SingleFlightOptions

      Returns (...args: Args) => R | undefined

      A function with the same parameters that either passes through the handler's return value or returns undefined when the call was suppressed.

      "In flight" means: the previous call's returned promise is still pending, OR the previous call settled (or ran synchronously) less than lockoutMs ago. Suppressed calls return undefined without invoking the handler. A rejected promise releases the gate like a resolved one and keeps its rejection semantics (the wrapped return value is passed through, so callers that void it today behave exactly as before).