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

Function eventTarget

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

Source from the content-addressed store, hash-verified

226}
227
228async function eventTarget() {
229 const et = new EventTarget();
230 const tick = () => et.dispatchEvent(new Event('tick'));
231 const interval = setInterval(tick, 0);
232 let count = 0;
233 for await (const [ event ] of on(et, 'tick')) {
234 count++;
235 assert.strictEqual(event.type, 'tick');
236 if (count >= 5) {
237 break;
238 }
239 }
240 assert.strictEqual(count, 5);
241 clearInterval(interval);
242}
243
244async function errorListenerCount() {
245 const et = new EventEmitter();

Callers

nothing calls this directly

Calls 3

clearIntervalFunction · 0.85
setIntervalFunction · 0.50
onFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…