Compose multiple AbortSignals with AND, OR, and timeout semantics
npm install signal-composeimport {anySignal, allSignals, timeoutSignal} from 'signal-compose';
const controller1 = new AbortController();
const controller2 = new AbortController();
// Abort when ANY signal aborts
const either = anySignal([controller1.signal, controller2.signal]);
// Abort when ALL signals have aborted
const both = allSignals([controller1.signal, controller2.signal]);
// Abort on signal OR timeout (5 seconds)
const withTimeout = timeoutSignal(controller1.signal, 5000);Returns an AbortSignal that aborts when ANY of the input signals abort. If any input signal is already aborted, the returned signal is immediately aborted.
Type: Iterable<AbortSignal>
The signals to monitor.
Returns an AbortSignal that aborts when ALL of the input signals have aborted. The reason will be the reason from the last signal to abort.
Type: Iterable<AbortSignal>
The signals to monitor.
Returns an AbortSignal that aborts when either the given signal aborts or the timeout expires, whichever comes first.
Type: AbortSignal
The signal to monitor.
Type: number
The timeout duration in milliseconds: a finite number between 0 and 2147483647. Invalid durations throw RangeError, including when the input signal is already aborted.
- abort-race - Race async operations with automatic AbortSignal cleanup
MIT