# uint8arraylist

> Append and consume bytes using only no-copy operations

Latest version **3.0.2** (published 2026-05-08) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install uint8arraylist
pnpm add uint8arraylist
yarn add uint8arraylist
bun add uint8arraylist
```

## Health

**Score 65/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2026-05-08 |
| First published | 2022-02-03 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 107.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 11 |
| Author | Alex Potsides |
| Maintainers | achingbrain |

## Links

- npm: https://www.npmjs.com/package/uint8arraylist
- Repository: https://github.com/achingbrain/uint8arraylist
- Homepage: https://github.com/achingbrain/uint8arraylist#readme
- Issues: https://github.com/achingbrain/uint8arraylist/issues
- npm.io page: https://npm.io/package/uint8arraylist

## Dependencies (1)

- [uint8arrays](https://npm.io/package/uint8arrays.md) ^6.0.0

## Recent versions

- 3.0.2 (latest) — 2026-05-08
- 3.0.1 — 2026-05-07
- 3.0.0 — 2026-05-07
- 2.4.9 — 2026-04-13
- 2.4.8 — 2023-12-30
- 2.4.7 — 2023-11-24
- 2.4.6 — 2023-11-24
- 2.4.5 — 2023-11-24
- 2.4.4 — 2023-11-24
- 2.4.3 — 2022-12-16
- 2.4.2 — 2022-11-24
- 2.4.1 — 2022-11-24
- 2.4.0 — 2022-11-24
- 2.3.3 — 2022-10-12
- 2.3.2 — 2022-08-06
- … 18 more at https://npm.io/package/uint8arraylist/versions

## README

# uint8arraylist

[![codecov](https://img.shields.io/codecov/c/github/achingbrain/uint8arraylist.svg?style=flat-square)](https://codecov.io/gh/achingbrain/uint8arraylist)
[![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/uint8arraylist/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/achingbrain/uint8arraylist/actions/workflows/js-test-and-release.yml?query=branch%3Amain)

> Append and consume bytes using only no-copy operations

# About

<!--

!IMPORTANT!

Everything in this README between "# About" and "# Install" is automatically
generated and will be overwritten the next time the doc generator is run.

To make changes to this section, please update the @packageDocumentation section
of src/index.js or src/index.ts

To experiment with formatting, please run "npm run docs" from the root of this
repo and examine the changes made.

-->

A class that lets you do operations over a list of Uint8Arrays without
copying them.

```js
import { Uint8ArrayList } from 'uint8arraylist'

const list = new Uint8ArrayList()
list.append(Uint8Array.from([0, 1, 2]))
list.append(Uint8Array.from([3, 4, 5]))

list.subarray()
// -> Uint8Array([0, 1, 2, 3, 4, 5])

list.consume(3)
list.subarray()
// -> Uint8Array([3, 4, 5])

// you can also iterate over the list
for (const buf of list) {
  // ..do something with `buf`
}

list.subarray(0, 1)
// -> Uint8Array([0])
```

## Converting Uint8ArrayLists to Uint8Arrays

There are two ways to turn a `Uint8ArrayList` into a `Uint8Array` - `.slice` and `.subarray` and one way to turn a `Uint8ArrayList` into a `Uint8ArrayList` with different contents - `.sublist`.

### slice

Slice follows the same semantics as [Uint8Array.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice) in that it creates a new `Uint8Array` and copies bytes into it using an optional offset & length.

```js
const list = new Uint8ArrayList()
list.append(Uint8Array.from([0, 1, 2]))
list.append(Uint8Array.from([3, 4, 5]))

list.slice(0, 1)
// -> Uint8Array([0])
```

### subarray

Subarray attempts to follow the same semantics as [Uint8Array.subarray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray) with one important different - this is a no-copy operation, unless the requested bytes span two internal buffers in which case it is a copy operation.

```js
const list = new Uint8ArrayList()
list.append(Uint8Array.from([0, 1, 2]))
list.append(Uint8Array.from([3, 4, 5]))

list.subarray(0, 1)
// -> Uint8Array([0]) - no-copy

list.subarray(2, 5)
// -> Uint8Array([2, 3, 4]) - copy
```

### sublist

Sublist creates and returns a new `Uint8ArrayList` that shares the underlying buffers with the original so is always a no-copy operation.

```js
const list = new Uint8ArrayList()
list.append(Uint8Array.from([0, 1, 2]))
list.append(Uint8Array.from([3, 4, 5]))

list.sublist(0, 1)
// -> Uint8ArrayList([0]) - no-copy

list.sublist(2, 5)
// -> Uint8ArrayList([2], [3, 4]) - no-copy
```

## Inspiration

Borrows liberally from [bl](https://www.npmjs.com/package/bl) but only uses native JS types.

# Install

```console
$ npm i uint8arraylist
```

## Browser `<script>` tag

Loading this module through a script tag will make its exports available as `Uint8arraylist` in the global namespace.

```html
<script src="https://unpkg.com/uint8arraylist/dist/index.min.js"></script>
```

# API Docs

- <https://achingbrain.github.io/uint8arraylist>

# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](https://github.com/achingbrain/uint8arraylist/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](https://github.com/achingbrain/uint8arraylist/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

# 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.

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