🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

abortable-timeout

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abortable-timeout

abortable timeout promise

3.0.5
latest
Source
npm
Version published
Weekly downloads
245
44.12%
Maintainers
1
Weekly downloads
 
Created
Source

abortable-timeout

abortable timeout promise via abortsignals

Installation

npm i --save abortable-timeout

Usage

Supports both ESM and CommonJS

// esm
import timeout from 'abortable-timeout`
// commonjs
const timeout = require('abortable-timeout').default

Example

import timeout from 'abortable-timeout`

const controller = new AbortController()
const signal = controller.signal

try {
  await timeout(1000, signal)
} catch(err) {
  if (err.name === 'AbortError') {
    console.warn('aborted')
    return
  }
  throw err
}

controller.abort()

License

MIT

Keywords

timeout

FAQs

Package last updated on 26 Apr 2024

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