events: allow use of AbortController with once
Allows an AbortSignal to be passed in to events.once() to cancel waiting on an event.
const ee = new EventEmitter();
const ac = new AbortController();
const p = events.once(ee, 'foo', { signal: ac.signal });
process.nextTick(() => ac.abort());
// p is rejected with an AbortError
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines