abortedAsync
Listens to abort event on the provided signal
and returns a promise that is fulfilled when the signal
is aborted. If the passed resource
is garbage collected before the signal
is aborted, the returned promise shall remain pending indefinitely.
import { aborted } from 'node:util';
const dependent = obtainSomethingAbortable();
aborted(dependent.signal, dependent).then(() => {
// Do something when dependent is aborted.
});
dependent.on('event', () => {
dependent.abort();
});
Content copied to clipboard
Since
v19.7.0
Parameters
resource
Any non-null entity, reference to which is held weakly.