Socket
Socket
Sign inDemoInstall

hypercore-byte-stream

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypercore-byte-stream - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

6

index.js

@@ -142,3 +142,6 @@ const assert = require('assert')

if (this._ended) return this.push(null)
if (this._range.length === 0) return this.push(null)
if (this._range.length === 0) {
this._cleanup()
return this.push(null)
}

@@ -150,2 +153,3 @@ if (!this._opened) {

if ((this._range.end !== -1 && this._range.start >= this._range.end) || this._range.length === 0) {
this._cleanup()
return this.push(null)

@@ -152,0 +156,0 @@ }

4

package.json
{
"name": "hypercore-byte-stream",
"version": "1.0.5",
"version": "1.0.6",
"description": "A Readable stream wrapper around Hypercore that supports reading byte ranges.",

@@ -25,3 +25,3 @@ "main": "index.js",

"devDependencies": {
"hypercore": "^6.24.0",
"hypercore": "^9.1.0",
"random-access-memory": "^3.1.1",

@@ -28,0 +28,0 @@ "tape": "^4.9.2"

@@ -36,4 +36,4 @@ const ram = require('random-access-memory')

let s1 = core1.replicate({ live: true })
s1.pipe(core2.replicate({ live: true })).pipe(s1)
let s1 = core1.replicate(true, { live: true })
s1.pipe(core2.replicate(false, { live: true })).pipe(s1)

@@ -40,0 +40,0 @@ let stream = createStream()

@@ -251,2 +251,60 @@ const test = require('tape')

})
test(`${tag}: _destroy is always called with empty ranges`, t => {
create(10, 100, (err, input, output, stream, records) => {
t.error(err, 'create stream ok')
stream.start({
feed: output,
byteOffset: 101,
byteLength: 99
})
stream.on('data', () => {})
stream.on('error', err => {
t.error(err)
})
const expectedSelections = output.sparse ? 0 : 1
stream.on('end', () => {
t.true(stream._ended)
t.false(stream._range)
t.same(output._selections.length, expectedSelections)
t.end()
})
})
})
test(`${tag}: _destroy always called for various ranges`, t => {
t.plan(3 * 7)
const byteRanges = [
[0, 0],
[0, 10],
[101, 150],
[900, -1],
[200, 300],
[350, 450],
[450, 750]
]
for (const [byteStart, byteEnd] of byteRanges) {
testDestroy(byteStart, byteEnd)
}
function testDestroy (byteStart, byteEnd) {
create(10, 100, (err, input, output, stream, records) => {
stream.start({
feed: output,
byteOffset: 101,
byteLength: 99
})
stream.on('data', () => {})
stream.on('error', err => {
t.error(err)
})
const expectedSelections = output.sparse ? 0 : 1
stream.on('end', () => {
t.true(stream._ended)
t.false(stream._range)
t.same(output._selections.length, expectedSelections)
})
})
}
})
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc