chunk-store-stream
Advanced tools
Comparing version 4.2.0 to 4.3.0
{ | ||
"name": "chunk-store-stream", | ||
"description": "Convert an abstract-chunk-store compliant store into a readable or writable stream", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh", |
@@ -1,5 +0,5 @@ | ||
# chunk-store-stream [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] | ||
# 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] | ||
[travis-image]: https://img.shields.io/travis/feross/chunk-store-stream/master.svg | ||
[travis-url]: https://travis-ci.org/feross/chunk-store-stream | ||
[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 | ||
@@ -6,0 +6,0 @@ [npm-url]: https://npmjs.org/package/chunk-store-stream |
@@ -15,4 +15,5 @@ const BlockStream = require('block-stream2') | ||
const zeroPadding = opts.zeroPadding === undefined ? false : opts.zeroPadding | ||
this._blockstream = new BlockStream(chunkLength, { zeroPadding }) | ||
this._blockstream = new BlockStream(chunkLength, { ...opts, zeroPadding }) | ||
this._outstandingPuts = 0 | ||
this._storeMaxOutstandingPuts = opts.storeMaxOutstandingPuts || 16 | ||
@@ -24,5 +25,11 @@ let index = 0 | ||
this._outstandingPuts += 1 | ||
if (this._outstandingPuts >= this._storeMaxOutstandingPuts) { | ||
this._blockstream.pause() | ||
} | ||
store.put(index, chunk, (err) => { | ||
if (err) return this.destroy(err) | ||
this._outstandingPuts -= 1 | ||
if (this._outstandingPuts < this._storeMaxOutstandingPuts) { | ||
this._blockstream.resume() | ||
} | ||
if (this._outstandingPuts === 0 && typeof this._finalCb === 'function') { | ||
@@ -29,0 +36,0 @@ this._finalCb(null) |
8203
105