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

Function abortableOnAfter

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

Source from the content-addressed store, hash-verified

290}
291
292async function abortableOnAfter() {
293 const ee = new EventEmitter();
294 const ac = new AbortController();
295
296 const i = setInterval(() => ee.emit('foo', 'foo'), 10);
297
298 async function foo() {
299 for await (const f of on(ee, 'foo', { signal: ac.signal })) {
300 assert.strictEqual(f, 'foo');
301 }
302 }
303
304 foo().catch(common.mustCall((error) => {
305 assert.strictEqual(error.name, 'AbortError');
306 })).finally(() => {
307 clearInterval(i);
308 });
309
310 process.nextTick(() => ac.abort());
311}
312
313async function eventTargetAbortableOnAfter() {
314 const et = new EventTarget();

Callers

nothing calls this directly

Calls 5

abortMethod · 0.95
clearIntervalFunction · 0.85
fooFunction · 0.70
setIntervalFunction · 0.50
emitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…