Comparing version 1.0.0 to 1.1.0
@@ -10,2 +10,3 @@ module.exports = encode | ||
offset = offset || 0 | ||
var oldOffset = offset | ||
@@ -17,3 +18,6 @@ while(num & MSBALL) { | ||
out[offset] = num | ||
encode.bytesWritten = offset - oldOffset + 1 | ||
return out | ||
} |
{ | ||
"name": "varint", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "protobuf-style varint bytes - use msb to create integer values of varying sizes", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -30,2 +30,6 @@ # varint | ||
### varint.encode.bytesWritten | ||
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. | ||
## usage notes | ||
@@ -32,0 +36,0 @@ |
@@ -63,2 +63,3 @@ var varint = require('./index') | ||
assert.deepEqual(encode(expected), [expected]) | ||
assert.equal(encode.bytesWritten, 1) | ||
assert.end() | ||
@@ -70,2 +71,3 @@ }) | ||
assert.deepEqual(encode(expected), [0x80, 0x1E]) | ||
assert.equal(encode.bytesWritten, 2) | ||
assert.end() | ||
@@ -72,0 +74,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
5385
102
44