Takes an async iterator and turns it into a browser readable stream
Turns an (async)iterable into a W3C ReadbleStream.
import toBrowserReadableStream from 'it-to-browser-readablestream'
// This can also be an iterator, async iterator, generator, etc
const values = [Buffer.from([0, 1]), Buffer.from([2, 3])]
const stream = await toBrowserReadableStream(values)
for await (const buf of stream) {
console.info(buf) // Buffer[0, 1]
}
$ npm i it-to-browser-readablestream
<script>
tagLoading this module through a script tag will make it's exports available as ItToBrowserReadablestream
in the global namespace.
<script src="https://unpkg.com/it-to-browser-readablestream/dist/index.min.js"></script>
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Turns an (async)iterable into a W3C ReadbleStream.
Example