Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@jcoreio/abortable

Package Overview
Dependencies
Maintainers
6
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jcoreio/abortable

memory-leak-proof function to wrap a promise to reject when a signal is aborted

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
6
Created
Source

@jcoreio/abortable

memory-leak-proof function to wrap a promise to reject when a signal is aborted

CircleCI Coverage Status semantic-release npm version

abortable(promise, signal)

Creates a promise that fulfills when the given promise fulfills, or rejects when the given signal is aborted, whichever comes first. If the signal is aborted, rejects with a DOMException with name: 'AbortError'.

Once the returned promise resolves or rejects, references to all promise and signal handlers will have been removed, so that it doesn't unexpectedly retain any memory.

import { abortable } from '@jcoreio/abortable'

const abortController = new AbortContorller()
const { signal } = abortController

const promise = abortable(new Promise((r) => setTimeout(r, 10000)), signal)

Keywords

signal

FAQs

Package last updated on 03 Dec 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