Options
All
  • Public
  • Public/Protected
  • All
Menu

Module concurrency/timeout

Index

Functions Async

Async Functions

  • timeout<T>(runner: T, timeout?: number): T
  • wrap an async function with timeout

    since

    5.15.0

    throws

    {TimeoutError}

    example
    const f = timeout(async() => {}, 1000)
    // f() will throw error if the result is not resolved in one second

    Type Parameters

    Parameters

    • runner: T

      async runner please, otherwise the timeout is not meaningful

    • timeout: number = ...

      timeout threshold in milliseconds, default value is 60 seconds

    Returns T