Comparing version 4.0.1 to 5.0.0
@@ -15,6 +15,5 @@ module.exports = read | ||
do { | ||
if(counter >= l) { | ||
if (counter >= l) { | ||
read.bytes = 0 | ||
read.bytesRead = 0 // DEPRECATED | ||
return undefined | ||
throw new RangeError('Could not decode varint') | ||
} | ||
@@ -21,0 +20,0 @@ b = buf[counter++] |
{ | ||
"name": "varint", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "protobuf-style varint bytes - use msb to create integer values of varying sizes", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,2 +28,4 @@ # varint | ||
Throws a `RangeError` when `data` does not represent a valid encoding. | ||
### varint.decode.bytes | ||
@@ -45,3 +47,3 @@ | ||
If varint is passed a buffer that does not contain a valid end | ||
byte, then `decode` will return undefined, and `decode.bytes` | ||
byte, then `decode` will throw `RangeError`, and `decode.bytes` | ||
will be set to 0. If you are reading from a streaming source, | ||
@@ -48,0 +50,0 @@ it's okay to pass an incomplete buffer into `decode`, detect this |
10
test.js
@@ -127,6 +127,8 @@ var varint = require('./index') | ||
while(l--) { | ||
var val = decode(buffer.slice(0, l)) | ||
assert.equal(val, undefined) | ||
assert.equal(decode.bytes, 0) | ||
assert.equal(decode.bytesRead, 0) | ||
try { | ||
var val = decode(buffer.slice(0, l)) | ||
} catch (err) { | ||
assert.equal(err.constructor, RangeError) | ||
assert.equal(decode.bytes, 0) | ||
} | ||
} | ||
@@ -133,0 +135,0 @@ assert.end() |
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
9027
234
54