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

Function next

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

Source from the content-addressed store, hash-verified

124}
125
126async function next() {
127 const ee = new EventEmitter();
128 const iterable = on(ee, 'foo');
129
130 process.nextTick(function() {
131 ee.emit('foo', 'bar');
132 ee.emit('foo', 42);
133 iterable.return();
134 });
135
136 const results = await Promise.all([
137 iterable.next(),
138 iterable.next(),
139 iterable.next(),
140 ]);
141
142 assert.deepStrictEqual(results, [{
143 value: ['bar'],
144 done: false,
145 }, {
146 value: [42],
147 done: false,
148 }, {
149 value: undefined,
150 done: true,
151 }]);
152
153 assert.deepStrictEqual(await iterable.next(), {
154 value: undefined,
155 done: true,
156 });
157}
158
159async function nextError() {
160 const ee = new EventEmitter();

Callers

nothing calls this directly

Calls 5

allMethod · 0.80
nextMethod · 0.65
onFunction · 0.50
emitMethod · 0.45
returnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…