You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

binary-extract

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-extract - npm Package Compare versions

Comparing version

to
0.0.1

.travis.yml

8

index.js

@@ -19,2 +19,3 @@

var mark = code('"');
var backslash = code('\\');

@@ -39,2 +40,8 @@ /**

c = buf[i];
if (c == backslash) {
i++;
continue;
}
if (c == mark) {

@@ -151,5 +158,4 @@ inString = !inString;

var json = buf.toString('utf8', start, end);
if (json[0] == '"') return json.slice(1, json.length - 1);
return JSON.parse(json);
}

4

package.json
{
"name": "binary-extract",
"description": "Extract a value from a binary json blob",
"version": "0.0.0",
"version": "0.0.1",
"repository": "segmentio/binary-extract",

@@ -16,2 +16,2 @@ "license": "MIT",

}
}
}

@@ -6,2 +6,4 @@

[![build status](https://secure.travis-ci.org/segmentio/binary-extract.png)](http://travis-ci.org/segmentio/binary-extract)
## Example

@@ -27,4 +29,8 @@

With the object from `bench.js`, `extract()` is ~2-4x faster than
`JSON.parse(buf.toString())`.
`JSON.parse(buf.toString())`. It is also way more memory efficient as the
blob stays out of the V8 heap.
The big perf gain comes mainly from not parsing everything and not
converting the buffer to a string.
## Installation

@@ -31,0 +37,0 @@

@@ -19,3 +19,3 @@

})
it('should ignore too nested values', function(){
it('should ignore too deeply nested values', function(){
var buf = toBuf({ foo: { beep: 'boop', bar: 'oops' }, bar: 'baz' });

@@ -38,2 +38,8 @@ equal(extract(buf, 'bar'), 'baz');

})
it('should escape with backslash', function(){
var buf = toBuf({ beep: '\"', foo: 'bar' });
equal(extract(buf, 'foo'), 'bar');
var buf = toBuf({ foo: 'bar\"baz' });
equal(extract(buf, 'foo'), 'bar\"baz');
});
})

@@ -40,0 +46,0 @@