# fs-chunk-store

> Filesystem (fs) chunk store that is abstract-chunk-store compliant

Latest version **5.0.1** (published 2026-05-25) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 45/100 (D)** — status: active.

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types.

Negative: declining downloads.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2026-05-25 |
| First published | 2015-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12.20.0 |
| Dependencies | 6 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 35 |
| Author | Feross Aboukhadijeh |
| Maintainers | feross, mafintosh, flet, watson, diegorbaquero, hicom150, jhiesey, webtorrent-bot, alxhotel |
| Keywords | abstract-chunk-store, chunk, filesystem, fs, store |

## Links

- npm: https://www.npmjs.com/package/fs-chunk-store
- Repository: https://github.com/webtorrent/fs-chunk-store
- Issues: https://github.com/webtorrent/fs-chunk-store/issues
- Funding: https://github.com/sponsors/feross
- npm.io page: https://npm.io/package/fs-chunk-store

## Dependencies (6)

- [thunky](https://npm.io/package/thunky.md) ^1.0.1
- [uint8-util](https://npm.io/package/uint8-util.md) ^2.2.5
- [run-parallel](https://npm.io/package/run-parallel.md) ^1.1.2
- [queue-microtask](https://npm.io/package/queue-microtask.md) ^1.2.2
- [random-access-file](https://npm.io/package/random-access-file.md) ^4.0.0
- [filename-reserved-regex](https://npm.io/package/filename-reserved-regex.md) ^3.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 5.0.1 (latest) — 2026-05-25
- 5.0.0 — 2025-08-03
- 4.1.0 — 2023-06-15
- 4.0.1 — 2023-01-27
- 4.0.0 — 2022-11-19
- 3.0.1 — 2022-07-03
- 3.0.0 — 2022-03-30
- 2.0.5 — 2022-03-30
- 2.0.4 — 2021-10-25
- 2.0.3 — 2021-02-09
- 2.0.2 — 2020-05-17
- 2.0.1 — 2019-08-14
- 2.0.0 — 2019-08-07
- 1.7.0 — 2018-04-04
- 1.6.5 — 2017-04-06
- … 16 more at https://npm.io/package/fs-chunk-store/versions

## README

# fs-chunk-store [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]

[travis-image]: https://img.shields.io/travis/feross/fs-chunk-store/master.svg
[travis-url]: https://travis-ci.org/feross/fs-chunk-store
[npm-image]: https://img.shields.io/npm/v/fs-chunk-store.svg
[npm-url]: https://npmjs.org/package/fs-chunk-store
[downloads-image]: https://img.shields.io/npm/dm/fs-chunk-store.svg
[downloads-url]: https://npmjs.org/package/fs-chunk-store
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com

#### Filesystem (fs) chunk store that is [abstract-chunk-store](https://github.com/mafintosh/abstract-chunk-store) compliant

[![abstract chunk store](https://cdn.rawgit.com/mafintosh/abstract-chunk-store/master/badge.svg)](https://github.com/mafintosh/abstract-chunk-store)

## Install

```
npm install fs-chunk-store
```

## Usage

### Back the store with a single file

``` js
var FSChunkStore = require('fs-chunk-store')

var chunks = new FSChunkStore(10, {
  path: '/tmp/my_file', // optional: path to file (default: temp file will be used)
  length: 100 // optional: file length in bytes (default: file expands based on `put`s)
})
```

### Back the store with multiple files

``` js
var FSChunkStore = require('fs-chunk-store')

var chunks = new FSChunkStore(10, {
  files: [
    { path: 'folder/file1.txt', length: 12 },
    { path: 'folder/file2.txt', length: 8 },
    { path: 'folder/file3.txt', length: 30 }
  ],
  path: 'C:/user/' // optional: if specified the file paths will be treated as relative, not absolute
})
```
Specifying a path to the store will create a folder in that path, and on destroy, will delete the folder along with all it's contents

### put, get, close, destroy

```js
chunks.put(0, Buffer.from('0123456789'), function (err) {
  if (err) throw err

  chunks.get(0, function (err, chunk) {
    if (err) throw err
    console.log(chunk) // '0123456789' as a buffer

    chunks.close(function (err) {
      if (err) throw err
      console.log('/tmp/my_file file descriptor is closed')

      chunks.destroy(function (err) {
        if (err) throw err
        console.log('/tmp/my_file file is deleted')
      })
    })
  })
})
```

## License

MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).

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