# chunk-store-iterator

> Convert an abstract-chunk-store compliant store into an async iterator, or write to using an async iterator.

Latest version **1.0.4** (published 2025-04-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install chunk-store-iterator
pnpm add chunk-store-iterator
yarn add chunk-store-iterator
bun add chunk-store-iterator
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2025-04-04 |
| First published | 2022-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ThaUnknown |
| Maintainers | thaunknown |
| Keywords | async, interator, stream, abstract-chunk-store, chunk, readable, writable, store, createReadStream, createWriteStream, read, write, convert |

## Links

- npm: https://www.npmjs.com/package/chunk-store-iterator
- Repository: https://github.com/ThaUnknown/chunk-store-iterator
- Homepage: https://github.com/ThaUnknown/chunk-store-iterator#readme
- Issues: https://github.com/ThaUnknown/chunk-store-iterator/issues
- npm.io page: https://npm.io/package/chunk-store-iterator

## Dependencies (1)

- [block-iterator](https://npm.io/package/block-iterator.md) ^1.1.1

## 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.0.4 (latest) — 2025-04-04
- 1.0.3 — 2023-01-25
- 1.0.2 — 2022-11-11
- 1.0.1 — 2022-11-11
- 1.0.0 — 2022-11-05

## README

# chunk-store-iterator [![javascript style guide][standard-image]][standard-url]

[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com

#### Convert an [abstract-chunk-store](https://github.com/mafintosh/abstract-chunk-store) store into an async iterator, or write to using an async iterator.

[![abstract chunk store](https://cdn.rawgit.com/mafintosh/abstract-chunk-store/master/badge.svg)](https://github.com/mafintosh/abstract-chunk-store)

A majorly simplified version of [chunk-store-stream](https://github.com/feross/chunk-store-stream). Dependency free and very fast.

Read/write data from/to a chunk store, with iterators.

## Install

```
npm install chunk-store-iterator
```

## Usage

### Create a read iterator

``` js
import { chunkStoreRead } from 'chunk-store-iterator'
import FSChunkStore from 'fs-chunk-store' // any chunk store will work
import { Readable } from 'streamx'

const chunkLength = 3
const store = new FSChunkStore(chunkLength)

// ... put some data in the store

const asyncIterator = chunkStoreRead(store, { length: 1200, zeroPadding: true })
const stream = Readable.from(asyncIterator)

stream.pipe(process.stdout)

// or

for await (const chunk of chunkStoreRead(store, { length: 1200 })) {
  console.log(chunk)
}
```

### Write using an iterator

```js
import { chunkStoreWrite } from 'chunk-store-iterator'
import FSChunkStore from 'fs-chunk-store' // any chunk store will work
import fs from 'fs'

const chunkLength = 3
const store = new FSChunkStore(chunkLength)

const stream = fs.createReadStream('file.txt')
await chunkStoreWrite(store, stream)
```

## License

MIT.

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