Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

length-prefixed-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

length-prefixed-stream - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

7

decode.js

@@ -12,4 +12,10 @@ var varint = require('varint')

this._limit = opts && opts.limit || 0
this._allowEmpty = !!(opts && opts.allowEmpty)
this._prefix = new Buffer(this._limit ? varint.encodingLength(this._limit) : 100)
this._ptr = 0
if (this._allowEmpty) {
this._readableState.highWaterMark = 16
this._readableState.objectMode = true
}
}

@@ -33,2 +39,3 @@

if (this._limit && this._missing > this._limit) return this._prefixError(data)
if (!this._missing && this._allowEmpty) this._push(Buffer(0))
this._ptr = 0

@@ -35,0 +42,0 @@ return offset + 1

5

package.json
{
"name": "length-prefixed-stream",
"version": "1.4.0",
"version": "1.5.0",
"description": "Streaming length prefixed buffers",

@@ -13,2 +13,3 @@ "main": "index.js",

"from2": "^2.1.0",
"standard": "^6.0.7",
"tape": "^2.14.0",

@@ -18,3 +19,3 @@ "through2": "^0.6.1"

"scripts": {
"test": "tape test.js"
"test": "standard && tape test.js"
},

@@ -21,0 +22,0 @@ "repository": {

@@ -248,1 +248,21 @@ var tape = require('tape')

})
tape('allow empty', function (t) {
var d = lpstream.decode()
d.on('data', function () {
t.fail('should not emit empty buffers')
})
d.on('end', function () {
d = lpstream.decode({allowEmpty: true})
d.on('data', function (data) {
t.same(data, Buffer(0), 'empty buffer')
t.end()
})
d.write(Buffer([0]))
d.end()
})
d.write(Buffer([0]))
d.end()
})
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