# browser-stream-util

> utility functions for web streams

Latest version **1.3.7** (published 2025-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install browser-stream-util
pnpm add browser-stream-util
yarn add browser-stream-util
bun add browser-stream-util
```

## Health

**Score 70/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.3.7 |
| Published | 2025-11-24 |
| First published | 2022-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | k0nsti |
| Keywords | stream, util |

## Links

- npm: https://www.npmjs.com/package/browser-stream-util
- Repository: https://github.com/k0nsti/browser-stream-util
- Homepage: https://github.com/k0nsti/browser-stream-util#readme
- Issues: https://github.com/k0nsti/browser-stream-util/issues
- npm.io page: https://npm.io/package/browser-stream-util

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.3.7 (latest) — 2025-11-24
- 1.3.6 — 2025-05-10
- 1.3.5 — 2025-05-07
- 1.3.4 — 2024-12-19
- 1.3.3 — 2024-11-20
- 1.3.2 — 2024-11-08
- 1.3.1 — 2024-11-02
- 1.3.0 — 2024-10-15
- 1.2.1 — 2024-05-20
- 1.2.0 — 2024-02-14
- 1.1.0 — 2023-03-13
- 1.0.0 — 2022-11-30

## README

[![npm](https://img.shields.io/npm/v/browser-stream-util.svg)](https://www.npmjs.com/package/browser-stream-util)
[![License](https://img.shields.io/badge/License-MIT--Clause-blue.svg)](https://spdx.org/licenses/MIT.html)
[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
[![bundlejs](https://deno.bundlejs.com/?q=browser-stream-util\&badge=detailed)](https://bundlejs.com/?q=browser-stream-util)
[![downloads](http://img.shields.io/npm/dm/browser-stream-util.svg?style=flat-square)](https://npmjs.org/package/browser-stream-util)
[![GitHub Issues](https://img.shields.io/github/issues/k0nsti/browser-stream-util.svg?style=flat-square)](https://github.com/k0nsti/browser-stream-util/issues)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fk0nsti%2Fbrowser-stream-util%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/k0nsti/browser-stream-util/goto)
[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Known Vulnerabilities](https://snyk.io/test/github/k0nsti/browser-stream-util/badge.svg)](https://snyk.io/test/github/k0nsti/browser-stream-util)
[![Coverage Status](https://coveralls.io/repos/k0nsti/browser-stream-util/badge.svg)](https://coveralls.io/github/k0nsti/browser-stream-util)

# browser-stream-util

utility functions for web streams

*   [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)

# API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

*   [iteratorToStream](#iteratortostream)
    *   [Parameters](#parameters)
*   [stringToStream](#stringtostream)
    *   [Parameters](#parameters-1)
*   [uint8ToStream](#uint8tostream)
    *   [Parameters](#parameters-2)
*   [streamToString](#streamtostring)
    *   [Parameters](#parameters-3)
*   [streamToUint8Array](#streamtouint8array)
    *   [Parameters](#parameters-4)
*   [streamToUint8Array](#streamtouint8array-1)
    *   [Parameters](#parameters-5)
*   [emptyStream](#emptystream)

## iteratorToStream

Converts an iterator into a ReadableStream.

### 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)>)**&#x20;

Returns **ReadableStream**&#x20;

## stringToStream

Encodes a string into a ReadableStream.

### Parameters

*   `str` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
*   `encoder` **[TextEncoder](https://developer.mozilla.org/docs/Web/API/TextEncoder)?**  (optional, default `new TextEncoder()`)

Returns **ReadableStream**&#x20;

## uint8ToStream

Encodes a uint8 array into a ReadableStream.

### Parameters

*   `array` **[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)**&#x20;

Returns **ReadableStream**&#x20;

## streamToString

Reads web stream content into a string.

### Parameters

*   `stream` **ReadableStream**&#x20;
*   `decoder` **[TextDecoder](https://developer.mozilla.org/docs/Web/API/TextDecoder)?**  (optional, default `new TextDecoder()`)

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;

## streamToUint8Array

Reads web stream content into a Uint8Array.

### Parameters

*   `stream` **ReadableStream**&#x20;
*   `maxByteLength` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**&#x20;

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)>**&#x20;

## streamToUint8Array

Reads web stream content into a Uint8Array.

### Parameters

*   `stream` **ReadableStream**&#x20;

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)>**&#x20;

## emptyStream

Delivers a zero length ReadableStream with no data.

Returns **ReadableStream**&#x20;

# install

With [npm](http://npmjs.org) do:

```shell
npm install browser-stream-util
```

# license

BSD-2-Clause

---
_Source: https://npm.io/package/browser-stream-util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
