# chunkchunk

> Variable sized rolling chunks. Good for deduplication.

Latest version **0.2.0** (published 2016-03-31) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-03-31 |
| First published | 2016-03-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Evan Verworn |
| Maintainers | xori |
| Keywords | variable, dedup, deduplication, rolling, hash |

## Links

- npm: https://www.npmjs.com/package/chunkchunk
- Repository: git@verworn.net:chunkchunk
- npm.io page: https://npm.io/package/chunkchunk

## Dependencies (1)

- [buzhash](https://npm.io/package/buzhash.md) ^0.0.2

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2016-03-31

## README

# Variable File Chunker

Uses the [BuzHash](http://git.verworn.net/buzhash) library to chop up files to
feature determined chunks. Good for deduplication.

    const ChunkChunk = require('chunkchunk'),
          fs = require('fs'),
          file = fs.openSync('my/file');

    const chunkee = new ChunkChunk(file, { max: 40000 })
    // create variable chunks of `my/file` to a maximum size
    // of 40k, with the default `min` chunk size of 50% of that.
    const chunk = chunkee.nextChunk();
    // { hash: 'sha256...', buffer: <Buffer ...> }
    const chunks = chunkee.toEnd();
    // [ {hash:.., buffer:<..>}, {...}]

    fs.close(file);

### Example Runs
The following is an example run of `npm test` chunking a ~120kb `.jpg` of
batman. First column is number of bytes in the chunk, with a max chunk setting
of 40k and a min of 20k. Second column is the sha256 of that chunk.

    [master] ~ npm test

    > chunkchunk@0.2.0 test C:\code\experiments\chunkchunk
    > node test/test

    4 chunks in 0s 30.234033ms
    39005   QQitkmhKkmWfrX+p59Nk49kctS1TrMHhpnFka08Bya4=
    34113   aOsmGJhJUeWNPPVbsyfqMyRx1F28rwQnvWiwwN/qVDo=
    21484   FX98NrA8OlKWzSGJpXIAslixSRU4QJBPBEVEkcc9EXA=
    23960   BY970o+31e5szl0TIGuDtfnPbH41tzWq2WYcK0Pn+1c=
    118562

## TODO

- [ ] Make ChunkChunk take a string, instead of a file descriptor.
- [ ] This library screams to be made a Transform Stream.
- [ ] Add config option for feature 'uniqueness'

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