timeout-signal
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i timeout-signal

    Weekly Downloads

    35,605

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    2.98 kB

    Total Files

    5

    Last publish

    Collaborators

    • richienb