# carstream

> Web stream CAR reader and writer.

Latest version **2.3.0** (published 2024-12-13) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2024-12-13 |
| First published | 2023-06-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 27.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alan Shaw |
| Maintainers | alanshaw |
| Keywords | CAR, stream, web, CID, IPLD |

## Links

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

## Dependencies (3)

- [multiformats](https://npm.io/package/multiformats.md) ^13.0.1
- [@ipld/dag-cbor](https://npm.io/package/@ipld/dag-cbor.md) ^9.0.3
- [uint8arraylist](https://npm.io/package/uint8arraylist.md) ^2.4.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.3.0 (latest) — 2024-12-13
- 2.2.0 — 2024-05-23
- 2.1.0 — 2024-04-30
- 2.0.0 — 2024-01-17
- 1.1.1 — 2023-12-12
- 1.1.0 — 2023-07-21
- 1.0.2 — 2023-06-26
- 1.0.1 — 2023-06-26
- 1.0.0 — 2023-06-25

## README

# carstream

[![Build](https://github.com/alanshaw/carstream/actions/workflows/build.yml/badge.svg)](https://github.com/alanshaw/carstream/actions/workflows/build.yml)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/carstream)](https://bundlephobia.com/package/carstream)

Web stream CAR reader and writer.

## Install

```
npm install carstream
```

## Usage

### Read a CAR

```js
import fs from 'node:fs'
import { Readable } from 'node:stream'
import { CARReaderStream } from 'carstream'

Readable.toWeb(fs.createReadStream('path/to/my.car'))
  .pipeThrough(new CARReaderStream())
  .pipeTo(new WritableStream({ write: block => console.log(block.cid.toString()) }))
```

### Write a CAR

```js
import fs from 'node:fs'
import { Writable } from 'node:stream'
import * as raw from 'multiformats/codecs/raw'
import { sha256 as hasher } from 'multiformats/hashes/sha2'
import * as Block from 'multiformats/block'
import { CARWriterStream } from 'carstream'

const readable = new ReadableStream({
  async pull (controller) {
    const block = await Block.encode({ value: new Uint8Array(), codec: raw, hasher })
    controller.enqueue(block)
    controller.close()
  }
})

await readable
  .pipeThrough(new CARWriterStream())
  .pipeTo(Writable.toWeb(fs.createWriteStream('path/to/my.car')))
```

## Contributing

Feel free to join in. All welcome. [Open an issue](https://github.com/alanshaw/carstream/issues)!

## License

Dual-licensed under [MIT / Apache 2.0](https://github.com/alanshaw/carstream/blob/main/LICENSE.md)

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