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

bipf

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bipf - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

17

index.js

@@ -275,3 +275,2 @@ var varint = require('varint')

var b_tag = varint.decode(buffer, start+c)
if(b_tag === t_tag && buffer.compare(target, t_start, t_length, start+c, start+c+t_length) === 0)

@@ -401,3 +400,3 @@ return start+c+(b_tag>>TAG_SIZE)+varint.decode.bytes

var type = tag & TAG_MASK
if(type == OBJECT) {
if(type === OBJECT) {
for(var c = varint.decode.bytes; c < len;) {

@@ -411,18 +410,16 @@ var key_start = start+c

var next_start = varint.decode.bytes + (value_tag >> TAG_SIZE)
iter(buffer, value_start, key_start)
if (iter(buffer, value_start, key_start)) return start
c += next_start
}
return start
}
else if(type == ARRAY) {
else if(type === ARRAY) {
var i = 0
for(var c = varint.decode.bytes; c < len;) {
iter(buffer, start+c, i)
var key_tag = varint.decode(buffer, start+c)
c += varint.decode.bytes + (key_tag >> TAG_SIZE)
if (iter(buffer, start+c, i++)) return start
var value_tag = varint.decode(buffer, start+c)
c += varint.decode.bytes + (value_tag >> TAG_SIZE)
}
}
return -1
return start
} else return -1
}

@@ -429,0 +426,0 @@

{
"name": "bipf",
"description": "binary in-place format",
"version": "1.3.0",
"version": "1.4.0",
"homepage": "https://github.com/dominictarr/binary",

@@ -6,0 +6,0 @@ "repository": {

@@ -195,2 +195,9 @@ # bipf

### iterate (buffer, start, fn) => void
If the field at `start` is an object or array, then `iterate` will call the `fn`
with arguments `fn(buffer, pointer, key)` for each subfield. If the field at
`start` is not an array or object, this returns `-1`. You can stop/abort the
iteration by making `fn` return any truthy value.
### seekKey (buffer, start, target) => pointer

@@ -197,0 +204,0 @@

@@ -49,3 +49,3 @@ var binary = require('../')

return c+l //read_value(c-2, b)
// c +=
// c +=
c+=l+2+l2+2

@@ -118,3 +118,3 @@ }

tape('iterate', function (t) {
tape('iterate object', function (t) {
var pkg_buf = Buffer.alloc(binary.encodingLength(pkg))

@@ -132,3 +132,20 @@ binary.encode(pkg, pkg_buf, 0)

tape('iterate array', function (t) {
var myarr = ['cat', 'dog', 'bird', 'elephant'];
var myarr_buf = Buffer.alloc(binary.encodingLength(myarr));
binary.encode(myarr, myarr_buf, 0);
var expectedResults = [
[0, 2, 'cat'],
[1, 6, 'dog'],
[2, 10, 'bird'],
[3, 15, 'elephant'],
];
binary.iterate(myarr_buf, 0, function (buffer, pointer, key) {
var expected = expectedResults.shift();
t.equal(key, expected[0], '' + expected[0]);
t.equal(pointer, expected[1], '' + expected[1]);
t.equal(binary.decode(buffer, pointer), expected[2], '' + expected[2]);
});
t.end();
});
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