You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
303 B
8 lines
303 B
import {once} from 'node:events';
|
|
|
|
// Combines `util.aborted()` and `events.addAbortListener()`: promise-based and cleaned up with a stop signal
|
|
export const onAbortedSignal = async (mainSignal, stopSignal) => {
|
|
if (!mainSignal.aborted) {
|
|
await once(mainSignal, 'abort', {signal: stopSignal});
|
|
}
|
|
};
|