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

Function onceError

test/parallel/test-events-once.js:107–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105}
106
107async function onceError() {
108 const ee = new EventEmitter();
109
110 const expected = new Error('kaboom');
111 process.nextTick(() => {
112 ee.emit('error', expected);
113 });
114
115 const promise = once(ee, 'error');
116 assert.strictEqual(ee.listenerCount('error'), 1);
117 const [ err ] = await promise;
118 assert.strictEqual(err, expected);
119 assert.strictEqual(ee.listenerCount('error'), 0);
120 assert.strictEqual(ee.listenerCount('myevent'), 0);
121}
122
123async function onceWithEventTarget() {
124 const et = new EventTarget();

Callers 1

Calls 3

listenerCountMethod · 0.80
onceFunction · 0.70
emitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…