MCPcopy Index your code
hub / github.com/nodejs/node / eventTargetAbortableOnAfter2

Function eventTargetAbortableOnAfter2

test/parallel/test-events-on-async-iterator.js:334–353  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

332}
333
334async function eventTargetAbortableOnAfter2() {
335 const et = new EventTarget();
336 const ac = new AbortController();
337
338 const i = setInterval(() => et.dispatchEvent(new Event('foo')), 10);
339
340 async function foo() {
341 for await (const f of on(et, 'foo', { signal: ac.signal })) {
342 assert(f);
343 // Cancel after a single event has been triggered.
344 ac.abort();
345 }
346 }
347
348 foo().catch(common.mustCall((error) => {
349 assert.strictEqual(error.name, 'AbortError');
350 })).finally(() => {
351 clearInterval(i);
352 });
353}
354
355async function abortableOnAfterDone() {
356 const ee = new EventEmitter();

Callers

nothing calls this directly

Calls 4

dispatchEventMethod · 0.95
clearIntervalFunction · 0.85
fooFunction · 0.70
setIntervalFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…