1.2.0 • Published 3 months ago
browser-stream-util v1.2.0
browser-stream-util
utility functions for web streams
API
Table of Contents
iteratorToStream
Converts an iterator into a web stream.
Parameters
iterator
(AsyncIterator[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | Iterator[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array))
Returns ReadableStream
stringToStream
Encodes a string into a web stream.
Parameters
str
stringencoder
TextEncoder (optional, defaultnew TextEncoder()
)
Returns ReadableStream
uint8ToStream
Encodes a uint8 array into a web stream.
Parameters
array
Uint8Array
Returns ReadableStream
streamToString
Reads web stream content into a string.
Parameters
stream
ReadableStreamdecoder
(optional, defaultnew TextDecoder()
)
Returns Promise[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
streamToUint8Array
Reads web stream content into a Uint8Array.
Parameters
stream
ReadableStream
Returns Promise[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
emptyStream
Delivers a zero length web stream with no data.
Returns ReadableStream
install
With npm do:
npm install browser-stream-util
license
BSD-2-Clause