Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

varint

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

varint - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

2

decode.js

@@ -15,3 +15,3 @@ module.exports = read

do {
if (counter >= l) {
if (counter >= l || shift > 49) {
read.bytes = 0

@@ -18,0 +18,0 @@ throw new RangeError('Could not decode varint')

@@ -9,2 +9,6 @@ module.exports = encode

function encode(num, out, offset) {
if (Number.MAX_SAFE_INTEGER && num > Number.MAX_SAFE_INTEGER) {
encode.bytes = 0
throw new RangeError('Could not encode varint')
}
out = out || []

@@ -11,0 +15,0 @@ offset = offset || 0

{
"name": "varint",
"version": "5.0.0",
"version": "5.0.1",
"description": "protobuf-style varint bytes - use msb to create integer values of varying sizes",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -80,3 +80,2 @@ var varint = require('./index')

bigs.push(Math.pow(2, i) - 1)
bigs.push(Math.pow(2, i))
})(i)

@@ -97,3 +96,3 @@

var MAX_INTD = Math.pow(2, 55)
var MAX_INTD = Number.MAX_SAFE_INTEGER
var MAX_INT = Math.pow(2, 31)

@@ -115,3 +114,3 @@

for(var i = 0; i <= 53; i++) {
var n = Math.pow(2, i)
var n = Math.pow(2, i) - 1
assert.equal(encode(n).length, encodingLength(n))

@@ -140,4 +139,22 @@ }

test('buffer too long', function (assert) {
var buffer = Uint8Array.from(
Array.from({length: 150}, function () { return 0xff })
.concat(Array.from({length: 1}, function () { return 0x1 }))
)
try {
var val = decode(buffer)
encode(val)
assert.fail('expected an error received value instead: ' + val)
} catch (err) {
assert.equal(err.constructor, RangeError)
assert.equal(decode.bytes, 0)
}
assert.end()
})
function randint(range) {
return Math.floor(Math.random() * range)
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc