Comparing version 2.0.0 to 3.0.0
@@ -26,5 +26,5 @@ module.exports = read | ||
read.bytesRead = counter - offset | ||
read.bytes = counter - offset | ||
return res | ||
} |
@@ -23,5 +23,5 @@ module.exports = encode | ||
encode.bytesWritten = offset - oldOffset + 1 | ||
encode.bytes = offset - oldOffset + 1 | ||
return out | ||
} |
{ | ||
"name": "varint", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "protobuf-style varint bytes - use msb to create integer values of varying sizes", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,9 +26,9 @@ # varint | ||
### varint.decode.bytesRead | ||
### varint.decode.bytes | ||
if you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytesRead`. this is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode. | ||
if you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`. this is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode. | ||
### varint.encode.bytesWritten | ||
### varint.encode.bytes | ||
similar to `bytesRead` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array). you can access this via `varint.encode.bytesWritten` which holds the number of bytes written in the last encode. | ||
similar to `decode.bytes` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array). you can access this via `varint.encode.bytes` which holds the number of bytes written in the last encode. | ||
@@ -35,0 +35,0 @@ |
14
test.js
@@ -16,3 +16,3 @@ var varint = require('./index') | ||
assert.equal(expect, data, 'fuzz test: ' + expect.toString()) | ||
assert.equal(decode.bytesRead, encoded.length) | ||
assert.equal(decode.bytes, encoded.length) | ||
} | ||
@@ -29,3 +29,3 @@ | ||
assert.equal(data, 300, 'should equal 300') | ||
assert.equal(decode.bytesRead, 2) | ||
assert.equal(decode.bytes, 2) | ||
assert.end() | ||
@@ -48,3 +48,3 @@ }) | ||
assert.equal(data, expected) | ||
assert.equal(decode.bytesRead, 1) | ||
assert.equal(decode.bytes, 1) | ||
assert.end() | ||
@@ -60,3 +60,3 @@ }) | ||
assert.equal(data, expected << 7) | ||
assert.equal(decode.bytesRead, 2) | ||
assert.equal(decode.bytes, 2) | ||
assert.end() | ||
@@ -68,3 +68,3 @@ }) | ||
assert.deepEqual(encode(expected), [expected]) | ||
assert.equal(encode.bytesWritten, 1) | ||
assert.equal(encode.bytes, 1) | ||
assert.end() | ||
@@ -76,3 +76,3 @@ }) | ||
assert.deepEqual(encode(expected), [0x80, 0x1E]) | ||
assert.equal(encode.bytesWritten, 2) | ||
assert.equal(encode.bytes, 2) | ||
assert.end() | ||
@@ -110,3 +110,3 @@ }) | ||
assert.equal(expect, data, 'fuzz test: ' + expect.toString()) | ||
assert.equal(decode.bytesRead, encoded.length) | ||
assert.equal(decode.bytes, encoded.length) | ||
} | ||
@@ -113,0 +113,0 @@ |
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
8681