Function
textStream
(chunks: ReadonlyArray<string>)
Source from the content-addressed store, hash-verified
| 831 | ) |
| 832 | |
| 833 | const textStream = (chunks: ReadonlyArray<string>): ReadableStream<Uint8Array> => { |
| 834 | let index = 0 |
| 835 | return new ReadableStream<Uint8Array>({ |
| 836 | pull(controller) { |
| 837 | if (index === chunks.length) { |
| 838 | controller.close() |
| 839 | } else { |
| 840 | controller.enqueue(textEncoder.encode(chunks[index++]!)) |
| 841 | } |
| 842 | } |
| 843 | }) |
| 844 | } |
| 845 | |
| 846 | const byteStream = (chunks: ReadonlyArray<Uint8Array>): ReadableStream<Uint8Array> => { |
| 847 | let index = 0 |
Tested by
no test coverage detected