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

Function onceAnEvent

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

Source from the content-addressed store, hash-verified

6const assert = require('assert');
7
8async function onceAnEvent() {
9 const ee = new EventEmitter();
10
11 process.nextTick(() => {
12 ee.emit('myevent', 42);
13 });
14
15 const [value] = await once(ee, 'myevent');
16 assert.strictEqual(value, 42);
17 assert.strictEqual(ee.listenerCount('error'), 0);
18 assert.strictEqual(ee.listenerCount('myevent'), 0);
19}
20
21async function onceAnEventWithInvalidOptions() {
22 const ee = new EventEmitter();

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…