Module it-to-browser-readablestream

Turns an (async)iterable into a W3C ReadbleStream.

Example

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]
}

it-to-browser-readablestream

codecov CI

Takes an async iterator and turns it into a browser readable stream

About

Turns an (async)iterable into a W3C ReadbleStream.

Example

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]
}

Install

$ npm i it-to-browser-readablestream

Browser <script> tag

Loading 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>

API Docs

License

Licensed under either of

Contribution

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.

Index

Functions