binary-parse-stream
Advanced tools
Comparing version 1.1.0 to 1.1.1
20
index.js
@@ -7,3 +7,3 @@ 'use strict'; | ||
var One = exports.One = { valueOf: function() { return 1 } } | ||
var One = exports.One = -1 | ||
@@ -18,2 +18,3 @@ inherits(BinaryParseStream, TransformStream) | ||
this._needed = 0 | ||
this._single = false | ||
this._parser = this._parse() | ||
@@ -28,6 +29,7 @@ } | ||
var needed = this._needed | ||
, single = this._single | ||
while (queue.length >= needed) { | ||
var chunk = queue.slice(0, +needed) | ||
queue = queue.slice(+needed) | ||
var chunk = queue.slice(0, needed) | ||
queue = queue.slice(needed) | ||
@@ -37,3 +39,3 @@ var ret | ||
try { | ||
if (needed === One) | ||
if (single) | ||
ret = this._parser.next(chunk[0]) | ||
@@ -48,4 +50,9 @@ else | ||
if (!ret.done) | ||
needed = ret.value | ||
if (!ret.done) { | ||
var value = ret.value | 0 | ||
single = value === One | ||
needed = single | ||
? 1 | ||
: value | ||
} | ||
else { | ||
@@ -63,3 +70,4 @@ if (err) | ||
this._needed = needed | ||
this._single = single | ||
return cb() | ||
} |
{ | ||
"name": "binary-parse-stream", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Painless streaming binary protocol parsers using generators.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
3452
58