MCPcopy Create free account
hub / github.com/angular/angular / timeEachNext

Function timeEachNext

packages/compiler-cli/preprocessor/ngp.ts:97–114  ·  view source on GitHub ↗

* Records each wait on `source.next()` as an `AwaitAnalysis` slice. Nothing else runs on the * main thread meanwhile, as `sliceAsync` requires.

(tracer: Tracer, source: AsyncIterable<T>)

Source from the content-addressed store, hash-verified

95 * main thread meanwhile, as `sliceAsync` requires.
96 */
97async function* timeEachNext<T>(tracer: Tracer, source: AsyncIterable<T>): AsyncGenerator<T> {
98 const iterator = source[Symbol.asyncIterator]();
99 let done = false;
100 try {
101 while (true) {
102 const next = await tracer.sliceAsync(SpanKind.AwaitAnalysis, () => iterator.next());
103 if (next.done) {
104 done = true;
105 return;
106 }
107 yield next.value;
108 }
109 } finally {
110 if (!done) {
111 await iterator.return?.();
112 }
113 }
114}
115
116async function writeDiagnosticsFile(
117 compiler: HybridCompiler,

Callers 1

runFunction · 0.85

Calls 2

sliceAsyncMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected