* Flatten transform yield to Uint8Array chunks (sync). * @yields {Uint8Array}
(value)
| 154 | * @yields {Uint8Array} |
| 155 | */ |
| 156 | function* 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). |
no test coverage detected
searching dependent graphs…