length-prefixed-message
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -9,2 +9,3 @@ var varint = require('varint'); | ||
var msglen = 0; | ||
var prev = null; | ||
var readable = function() { | ||
@@ -14,2 +15,6 @@ if (!msglen) { | ||
if (!buf) return; | ||
if (prev) { | ||
buf = Buffer.concat([prev, buf]); | ||
prev = null; | ||
} | ||
@@ -23,3 +28,3 @@ for (var i = 0; i < buf.length; i++) { | ||
if (!msglen) { | ||
stream.unshift(buf); | ||
prev = buf; | ||
return; | ||
@@ -26,0 +31,0 @@ } |
{ | ||
"name": "length-prefixed-message", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Reads and writes binary length prefixed messages. ", | ||
@@ -26,3 +26,4 @@ "main": "index.js", | ||
"tape": "^2.14.0", | ||
"concat-stream": "^1.4.6" | ||
"concat-stream": "^1.4.6", | ||
"choppa": "^1.0.0" | ||
}, | ||
@@ -29,0 +30,0 @@ "dependencies": { |
10
test.js
@@ -5,2 +5,3 @@ var fs = require('fs'); | ||
var lpm = require('./'); | ||
var choppa = require('choppa'); | ||
var varint = require('varint'); | ||
@@ -15,2 +16,11 @@ | ||
test('.read with chunked stream', function(t) { | ||
var chp = choppa(); | ||
fs.createReadStream('./fixtures2').pipe(chp); | ||
lpm.read(chp, function(buf) { | ||
t.equal(buf.toString().substr(0, 33), 'As Gregor Samsa awoke one morning'); | ||
t.end(); | ||
}); | ||
}); | ||
test('.write', function(t) { | ||
@@ -17,0 +27,0 @@ var stream = concat(function(buff) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11690
9
113
3
4