JSPM

timeout-signal

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1274597
  • Score
    100M100P100Q187251F
  • License MIT

Create an AbortSignal that aborts after a delay

Package Exports

  • timeout-signal

Readme

timeout-signal

Create an AbortSignal that aborts after a delay

Install

npm install timeout-signal

Usage

import timeoutSignal from 'timeout-signal';

try {
    const response = await fetch('https://www.google.com', {signal: timeoutSignal(5000)});
    // Handle response
} catch (error) {
    if (signal.aborted) {
        // Handle abortion
    }
}

API

timeoutSignal(timeout)

timeout

Type: integer

The milliseconds to wait.