# crc32-stream

> a streaming CRC32 checksumer

Latest version **7.0.1** (published 2024-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install crc32-stream
pnpm add crc32-stream
yarn add crc32-stream
bun add crc32-stream
```

## Health

**Score 53/100 (C)** — status: stable.

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 7.0.1 |
| Published | 2024-10-14 |
| First published | 2014-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/crc32-stream) |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Chris Talkington |
| Maintainers | ctalkington |
| Keywords | crc32-stream, crc32, stream, checksum |

## Links

- npm: https://www.npmjs.com/package/crc32-stream
- Repository: https://github.com/archiverjs/node-crc32-stream
- Issues: https://github.com/archiverjs/node-crc32-stream/issues
- npm.io page: https://npm.io/package/crc32-stream

## Dependencies (2)

- [crc-32](https://npm.io/package/crc-32.md) ^1.2.0
- [readable-stream](https://npm.io/package/readable-stream.md) ^4.0.0

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

- 7.0.1 (latest) — 2024-10-14
- 7.0.0 — 2024-10-13
- 6.0.0 — 2024-02-29
- 5.0.1 — 2024-02-29
- 5.0.0 — 2023-09-02
- 4.0.3 — 2023-09-02
- 4.0.2 — 2021-02-04
- 4.0.1 — 2020-11-19
- 4.0.0 — 2020-07-18
- 3.0.1 — 2019-08-02
- 3.0.0 — 2019-04-29
- 2.0.0 — 2017-02-13
- 1.0.1 — 2017-01-13
- 1.0.0 — 2016-04-06
- 0.4.0 — 2015-11-24
- … 11 more at https://npm.io/package/crc32-stream/versions

## README

# CRC32 Stream

crc32-stream is a streaming CRC32 checksumer. It uses the [crc](https://www.npmjs.org/package/crc) module behind the scenes to reliably handle binary data and fancy character sets. Data is passed through untouched.

### Install

```bash
npm install crc32-stream --save
```

You can also use `npm install https://github.com/archiverjs/node-crc32-stream/archive/master.tar.gz` to test upcoming versions.

### Usage

#### CRC32Stream

Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) options and methods.

```js
import { CRC32Stream } from "crc32-stream";

const source = fs.createReadStream("file.txt");
const checksum = new CRC32Stream();

checksum.on("end", function (err) {
  // do something with checksum.digest() here
});

// either pipe it
source.pipe(checksum);

// or write it
checksum.write("string");
checksum.end();
```

#### DeflateCRC32Stream

Inherits [zlib.DeflateRaw](http://nodejs.org/api/zlib.html#zlib_class_zlib_deflateraw) options and methods.

```js
import { DeflateCRC32Stream } from "crc32-stream";

const source = fs.createReadStream("file.txt");
const checksum = new DeflateCRC32Stream();

checksum.on("end", function (err) {
  // do something with checksum.digest() here
});

// either pipe it
source.pipe(checksum);

// or write it
checksum.write("string");
checksum.end();
```

### Instance API

#### digest()

Returns the checksum digest in unsigned form.

#### hex()

Returns the hexadecimal representation of the checksum digest. (ie E81722F0)

#### size(compressed)

Returns the raw size/length of passed-through data.

If `compressed` is `true`, it returns compressed length instead. (DeflateCRC32Stream)

## Things of Interest

- [Changelog](https://github.com/archiverjs/node-crc32-stream/releases)
- [Contributing](https://github.com/archiverjs/node-crc32-stream/blob/master/CONTRIBUTING.md)
- [MIT License](https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT)

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