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

timeout-abort-controller

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timeout-abort-controller

An AbortController that aborts after a specified timeout

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

timeout-abort-controller

Build Status dependencies Status JavaScript Style Guide

An AbortController that aborts after a specified timeout.

timeout-abort-controller uses retimer internally to help reduce the impact of having numerous timers running.

Install

npm install timeout-abort-controller

Usage

const { AbortController } = require('native-abort-controller')
const { TimeoutController } = require('timeout-abort-controller')
const anySignal = require('any-signal')

const userController = new AbortController()
// Aborts after 1 second
const timeoutController = new TimeoutController(1000)

const combinedSignal = anySignal([userController.signal, timeoutController.signal])
combinedSignal.addEventListener('abort', () => console.log('Abort!'))

// The user or the timeout can now abort the action
await performSomeAction({ signal: combinedSignal })
timeoutController.clear()

API

new TimeoutController(ms)

Creates an AbortController compliant TimeoutController.

Parameters
NameTypeDescription
msnumberThe time in milliseconds for when the TimeoutController should abort

timeoutController.clear()

Clears the internal timer.

timeoutController.abort()

Aborts the controller and clears the internal timeout.

timeoutController.reset()

Clears the timer and sets the internal timeout to occur after the ms timeout it was created with.

LICENSE

MIT © Jacob Heun

FAQs

Package last updated on 12 Jan 2022

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