https://github.com/feross/chunk-store-stream
Convert an abstract-chunk-store compliant store into a readable or writable stream
https://github.com/feross/chunk-store-stream
abstract-chunk-store chunk-store chunk-store-stream javascript nodejs stream streams
Last synced: 4 months ago
JSON representation
Convert an abstract-chunk-store compliant store into a readable or writable stream
- Host: GitHub
- URL: https://github.com/feross/chunk-store-stream
- Owner: feross
- License: mit
- Created: 2015-08-22T16:21:02.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-07-04T17:03:33.000Z (over 3 years ago)
- Last Synced: 2025-01-03T02:53:08.217Z (about 1 year ago)
- Topics: abstract-chunk-store, chunk-store, chunk-store-stream, javascript, nodejs, stream, streams
- Language: JavaScript
- Size: 41 KB
- Stars: 25
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chunk-store-stream [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[ci-image]: https://img.shields.io/github/workflow/status/feross/chunk-store-stream/ci/master
[ci-url]: https://github.com/feross/chunk-store-stream/actions
[npm-image]: https://img.shields.io/npm/v/chunk-store-stream.svg
[npm-url]: https://npmjs.org/package/chunk-store-stream
[downloads-image]: https://img.shields.io/npm/dm/chunk-store-stream.svg
[downloads-url]: https://npmjs.org/package/chunk-store-stream
[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 a readable or writable stream
[](https://github.com/mafintosh/abstract-chunk-store)
Read/write data from/to a chunk store, with streams.
## Install
```
npm install chunk-store-stream
```
## Usage
### Create a read stream
``` js
const { ChunkStoreReadStream } = require('chunk-store-stream')
const FSChunkStore = require('fs-chunk-store') // any chunk store will work
const chunkLength = 3
const store = new FSChunkStore(chunkLength)
// ... put some data in the store
const stream = new ChunkStoreReadStream(store, chunkLength, { length: 6 })
stream.pipe(process.stdout)
```
### Create a write stream
```js
const { ChunkStoreWriteStream } = require('chunk-store-stream')
const FSChunkStore = require('fs-chunk-store') // any chunk store will work
const fs = require('fs')
const chunkLength = 3
const store = new FSChunkStore(chunkLength)
const stream = new ChunkStoreWriteStream(store, chunkLength)
fs.createReadStream('file.txt').pipe(stream)
```
## License
MIT. Copyright (c) [Feross Aboukhadijeh](https://feross.org).