2.0.0 • Published 1 year ago

timeout-signal v2.0.0

Weekly downloads
3,259
License
MIT
Repository
github
Last release
1 year ago

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.