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

Function normalizeBatch

lib/internal/streams/iter/classic.js:107–124  ·  view source on GitHub ↗
(raw)

Source from the content-addressed store, hash-verified

105// Readable into Uint8Array values. Returns the normalized batch,
106// or null if normalization produced no output.
107async function normalizeBatch(raw) {
108 const batch = [];
109 for (let i = 0; i < raw.length; i++) {
110 const value = raw[i];
111 if (isUint8Array(value)) {
112 ArrayPrototypePush(batch, value);
113 } else {
114 // normalizeAsyncValue may await for async protocols (e.g.
115 // toAsyncStreamable on yielded objects). Stream events during
116 // the suspension are queued, not lost -- errors will surface
117 // on the next loop iteration after this yield completes.
118 for await (const normalized of normalizeAsyncValue(value)) {
119 ArrayPrototypePush(batch, normalized);
120 }
121 }
122 }
123 return batch.length > 0 ? batch : null;
124}
125
126// Batched async iterator for Readable streams. Same mechanism as
127// createAsyncIterator (same event setup, same stream.read() to

Callers

nothing calls this directly

Calls 2

isUint8ArrayFunction · 0.85
normalizeAsyncValueFunction · 0.85

Tested by

no test coverage detected