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

Function flattenTransformYieldAsync

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

* Flatten transform yield to Uint8Array chunks (async). * @yields {Uint8Array}

(value)

Source from the content-addressed store, hash-verified

188 * @yields {Uint8Array}
189 */
190async function* flattenTransformYieldAsync(value) {
191 if (isUint8Array(value)) {
192 yield value;
193 return;
194 }
195 if (typeof value === 'string') {
196 yield toUint8Array(value);
197 return;
198 }
199 if (isAnyArrayBuffer(value)) {
200 yield new Uint8Array(value);
201 return;
202 }
203 if (ArrayBufferIsView(value)) {
204 yield arrayBufferViewToUint8Array(value);
205 return;
206 }
207 // Check for async iterable first
208 if (isAsyncIterable(value)) {
209 for await (const item of value) {
210 yield* flattenTransformYieldAsync(item);
211 }
212 return;
213 }
214 // Must be sync Iterable<TransformYield>, no nested async iterables
215 if (isSyncIterable(value)) {
216 for (const item of value) {
217 yield* flattenTransformYieldSync(item);
218 }
219 return;
220 }
221 throw new ERR_INVALID_ARG_TYPE(
222 'value',
223 ['Uint8Array', 'string', 'ArrayBuffer', 'ArrayBufferView',
224 'Iterable', 'AsyncIterable'],
225 value);
226}
227
228/**
229 * Process transform result (sync).

Callers 2

Calls 6

isUint8ArrayFunction · 0.85
toUint8ArrayFunction · 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…