MCPcopy Index your code
hub / github.com/nodejs/node / [SymbolAsyncIterator]

Method [SymbolAsyncIterator]

lib/internal/fs/recursive_watch.js:261–291  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

259 }
260
261 [SymbolAsyncIterator]() {
262 const { signal } = this.#options;
263 const promiseExecutor = signal == null ?
264 (resolve) => {
265 this.once('change', (eventType, filename) => {
266 resolve({ __proto__: null, value: { eventType, filename } });
267 });
268 } : (resolve, reject) => {
269 const onAbort = () => {
270 this.close();
271 reject(new AbortError(undefined, { cause: signal.reason }));
272 };
273 if (signal.aborted) return onAbort();
274 kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation;
275 signal.addEventListener('abort', onAbort, { __proto__: null, once: true, [kResistStopPropagation]: true });
276 this.once('change', (eventType, filename) => {
277 signal.removeEventListener('abort', onAbort);
278 resolve({ __proto__: null, value: { eventType, filename } });
279 });
280 };
281 return {
282 next: () => (this.#closed ?
283 { __proto__: null, done: true } :
284 new Promise(promiseExecutor)),
285 return: () => {
286 this.close();
287 return { __proto__: null, done: true };
288 },
289 [SymbolAsyncIterator]() { return this; },
290 };
291 }
292}
293
294module.exports = {

Callers

nothing calls this directly

Calls 7

closeMethod · 0.95
addEventListenerMethod · 0.65
removeEventListenerMethod · 0.65
resolveFunction · 0.50
onAbortFunction · 0.50
requireFunction · 0.50
onceMethod · 0.45

Tested by

no test coverage detected