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

Function next

lib/events.js:1098–1127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1096
1097 const iterator = ObjectSetPrototypeOf({
1098 next() {
1099 // First, we consume all unread events
1100 if (size) {
1101 const value = unconsumedEvents.shift();
1102 size--;
1103 if (paused && size < lowWatermark) {
1104 emitter.resume(); // Can not be finished yet
1105 paused = false;
1106 }
1107 return PromiseResolve(createIterResult(value, false));
1108 }
1109
1110 // Then we error, if an error happened
1111 // This happens one time if at all, because after 'error'
1112 // we stop listening
1113 if (error) {
1114 const p = PromiseReject(error);
1115 // Only the first element errors
1116 error = null;
1117 return p;
1118 }
1119
1120 // If the iterator is finished, resolve to done
1121 if (finished) return closeHandler();
1122
1123 // Wait until an event happens
1124 return new Promise(function(resolve, reject) {
1125 unconsumedPromises.push({ resolve, reject });
1126 });
1127 },
1128
1129 return() {
1130 return closeHandler();

Callers 3

configure_nodeFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50

Calls 5

createIterResultFunction · 0.85
closeHandlerFunction · 0.85
resumeMethod · 0.65
shiftMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…