Skip to content

Utility functions to use and combine `AbortSignal` and `AbortController` with Promises

License

Notifications You must be signed in to change notification settings

yoloforks/abort-utils

 
 

Repository files navigation

abort-utils

Utility functions to use and combine AbortSignal and AbortController with Promises

Install

npm install abort-utils
import {
	onAbort,
	mergeSignals,
	promiseFromSignal
} from 'abort-utils';

Usage

This package exports various utilities, just import what you need.

  • onAbort: Add multiple callbacks, observers and other abort controllers to a single signal.
  • mergeSignals: Create a new signal that aborts when any of the input signals aborts.
  • linkControllers: Link multiple controllers so that when one aborts, they all abort with the same reason.
  • promiseFromSignal: Create a Promise that resolves or rejects when the signal aborts.

License

MIT © Federico Brigante

About

Utility functions to use and combine `AbortSignal` and `AbortController` with Promises

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%