varint assert.

This commit is contained in:
Christopher Jeffrey 2016-05-16 17:05:36 -07:00
parent f0cc2f8c6c
commit e354dea283
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -336,7 +336,11 @@ BufferWriter.prototype.writeDoubleBE = function writeDoubleBE(value) {
*/
BufferWriter.prototype.writeVarint = function writeVarint(value) {
assert(value >= 0);
if (typeof value === 'number')
assert(value >= 0);
else
assert(!value.isNeg());
this.written += utils.sizeVarint(value);
this.data.push([VARINT, value]);
};