common-stuff
    Preparing search index...

    Function timeout

    • Rejects with a [[TimeoutError]] if promise doesn't settle within ms milliseconds.

      The original promise still runs to completion — there's no cancellation primitive in JS — but the returned promise won't wait for it.

      Type Parameters

      • T

      Parameters

      • promise: Promise<T>
      • ms: number

      Returns Promise<T>

      await timeout(fetch('/slow'), 5000)