Socket
Socket
Sign inDemoInstall

chunk-store-stream

Package Overview
Dependencies
6
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.1 to 4.2.0

2

package.json
{
"name": "chunk-store-stream",
"description": "Convert an abstract-chunk-store compliant store into a readable or writable stream",
"version": "4.1.1",
"version": "4.2.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh",

@@ -16,17 +16,30 @@ const stream = require('readable-stream')

const offset = opts.offset || 0
this._store = store
this._chunkLength = chunkLength
this._index = 0
this._index = Math.floor(offset / chunkLength)
this._chunkOffset = offset % chunkLength
this._consumedLength = 0
}
_read () {
if (this._index * this._chunkLength >= this._length) {
const remainingLength = this._length - this._consumedLength
if (remainingLength <= 0) {
this.push(null)
} else {
this._store.get(this._index, (err, chunk) => {
const offset = this._chunkOffset
const length = Math.min(remainingLength, this._chunkLength - this._chunkOffset)
this._chunkOffset = 0
this._consumedLength += length
this._store.get(this._index, {
offset,
length
}, (err, chunk) => {
if (err) return this.destroy(err)
this.push(chunk)
})
this._index += 1
}
this._index += 1
}

@@ -33,0 +46,0 @@

@@ -14,3 +14,4 @@ const BlockStream = require('block-stream2')

this._blockstream = new BlockStream(chunkLength, { zeroPadding: false })
const zeroPadding = opts.zeroPadding === undefined ? false : opts.zeroPadding
this._blockstream = new BlockStream(chunkLength, { zeroPadding })
this._outstandingPuts = 0

@@ -23,3 +24,4 @@

this._outstandingPuts += 1
store.put(index, chunk, () => {
store.put(index, chunk, (err) => {
if (err) return this.destroy(err)
this._outstandingPuts -= 1

@@ -26,0 +28,0 @@ if (this._outstandingPuts === 0 && typeof this._finalCb === 'function') {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc