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

Function flattenTransformYieldSync

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

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

(value)

Source from the content-addressed store, hash-verified

154 * @yields {Uint8Array}
155 */
156function* flattenTransformYieldSync(value) {
157 if (isUint8Array(value)) {
158 yield value;
159 return;
160 }
161 if (typeof value === 'string') {
162 yield toUint8Array(value);
163 return;
164 }
165 if (isAnyArrayBuffer(value)) {
166 yield new Uint8Array(value);
167 return;
168 }
169 if (ArrayBufferIsView(value)) {
170 yield arrayBufferViewToUint8Array(value);
171 return;
172 }
173 // Must be Iterable<TransformYield>
174 if (isSyncIterable(value)) {
175 for (const item of value) {
176 yield* flattenTransformYieldSync(item);
177 }
178 return;
179 }
180 throw new ERR_INVALID_ARG_TYPE(
181 'value',
182 ['Uint8Array', 'string', 'ArrayBuffer', 'ArrayBufferView', 'Iterable'],
183 value);
184}
185
186/**
187 * Flatten transform yield to Uint8Array chunks (async).

Callers 4

Calls 4

isUint8ArrayFunction · 0.85
toUint8ArrayFunction · 0.85
isSyncIterableFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…