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

Function processTransformResultAsync

lib/internal/streams/iter/pull.js:322–399  ·  view source on GitHub ↗

* Process transform result (async). * @yields {Uint8Array[]}

(result)

Source from the content-addressed store, hash-verified

320 * @yields {Uint8Array[]}
321 */
322async function* processTransformResultAsync(result) {
323 // Handle Promise
324 if (isPromise(result)) {
325 const resolved = await result;
326 yield* processTransformResultAsync(resolved);
327 return;
328 }
329 if (result === null) {
330 return;
331 }
332 // Single Uint8Array -> wrap as batch
333 if (isUint8Array(result)) {
334 yield [result];
335 return;
336 }
337 // String -> UTF-8 encode and wrap as batch
338 if (typeof result === 'string') {
339 yield [toUint8Array(result)];
340 return;
341 }
342 // ArrayBuffer / ArrayBufferView -> convert and wrap
343 if (isAnyArrayBuffer(result)) {
344 yield [new Uint8Array(result)];
345 return;
346 }
347 if (ArrayBufferIsView(result)) {
348 yield [arrayBufferViewToUint8Array(result)];
349 return;
350 }
351 // Uint8Array[] batch
352 if (isUint8ArrayBatch(result)) {
353 if (result.length > 0) {
354 yield result;
355 }
356 return;
357 }
358 // Check for async iterable/generator first
359 if (isAsyncIterable(result)) {
360 const batch = [];
361 for await (const item of result) {
362 if (isUint8Array(item)) {
363 ArrayPrototypePush(batch, item);
364 continue;
365 }
366 for await (const chunk of flattenTransformYieldAsync(item)) {
367 ArrayPrototypePush(batch, chunk);
368 }
369 }
370 if (batch.length > 0) {
371 yield batch;
372 }
373 return;
374 }
375 // Sync Iterable or Generator
376 if (isSyncIterable(result)) {
377 const batch = [];
378 for (const item of result) {
379 if (isUint8Array(item)) {

Calls 8

isUint8ArrayFunction · 0.85
toUint8ArrayFunction · 0.85
isUint8ArrayBatchFunction · 0.85
isAsyncIterableFunction · 0.70
isSyncIterableFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…