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

Function errorDelayed

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

Source from the content-addressed store, hash-verified

77}
78
79async function errorDelayed() {
80 const ee = new EventEmitter();
81 const _err = new Error('kaboom');
82 process.nextTick(() => {
83 ee.emit('foo', 42);
84 ee.emit('error', _err);
85 });
86
87 const iterable = on(ee, 'foo');
88 const expected = [[42]];
89 let thrown = false;
90
91 try {
92 for await (const event of iterable) {
93 const current = expected.shift();
94 assert.deepStrictEqual(current, event);
95 }
96 } catch (err) {
97 thrown = true;
98 assert.strictEqual(err, _err);
99 }
100 assert.strictEqual(thrown, true);
101 assert.strictEqual(ee.listenerCount('foo'), 0);
102 assert.strictEqual(ee.listenerCount('error'), 0);
103}
104
105async function throwInLoop() {
106 const ee = new EventEmitter();

Callers

nothing calls this directly

Calls 4

listenerCountMethod · 0.80
onFunction · 0.50
emitMethod · 0.45
shiftMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…