Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timeout-signal

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timeout-signal

Create an AbortSignal that aborts after a delay.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
273K
increased by418.92%
Maintainers
1
Weekly downloads
 
Created
Source

timeout-signal Travis CI Build Status

Create an AbortSignal that aborts after a delay.

NPM Badge

Install

npm install timeout-signal

Usage

const timeoutSignal = require("timeout-signal");
const fetch = require("cross-fetch");

try {
	const response = await fetch("https://www.google.com", { signal: timeoutSignal(5000) })
	// Handle response
} catch (error) {
	if (error.message === "The user aborted a request.") {
		// Handle abortion
	}
}

API

timeoutSignal(timeout)

timeout

Type: integer

The milliseconds to wait.

timeoutSignal.clear(signal)

Clear the timeout associated with a signal.

signal

Type: Return value from timeoutSignal()

The signal to clear the timeout for.

const timeoutSignal = require("timeout-signal");
const fetch = require("cross-fetch");

const signal = timeoutSignal(5000)

try {
	const response = await fetch("https://www.google.com", { signal })
	timeoutSignal.clear(signal)
	// Handle response
} catch (error) {
	if (error.message === "The user aborted a request.") {
		// Handle abortion
	}
}

Keywords

FAQs

Package last updated on 26 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc