Popularity
2.3
Growing
Activity
0.0
Stable
153
7
5

Code Quality Rank: L3
Monthly Downloads: 0
Programming language: JavaScript
License: MIT License
Tags: Parsing    
Latest version: v0.1.2

binary-extract alternatives and similar modules

Based on the "Parsing" category.
Alternatively, view binary-extract alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of binary-extract or a related project?

Add another 'Parsing' Module

README

binary-extract

Extract one or more values from a buffer of json without parsing the whole thing.

build status

Example

var extract = require('binary-extract');

var buf = new Buffer(JSON.stringify({
  foo: 'bar',
  bar: 'baz',
  nested: {
    bar: 'nope'  
  } 
}));

var value = extract(buf, 'bar');
// => 'baz'

var values = extract(buf, ['foo', 'nested'])
// => ["bar", {"bar":"nope"}]

Perf

With the object from bench.js, extract() is ~2-4x faster than 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

$ npm install binary-extract

API

extract(buf, keys)

Extract the value of keys in the json buf.

The value can be any valid JSON structure.

If keys is a String, returns a value. If keys is an Array of keys, returns an array of values.

Sponsors

This module is proudly supported by my Sponsors!

Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my Patreon. Not sure how much of my modules you're using? Try feross/thanks!

License

MIT


*Note that all licence references and agreements mentioned in the binary-extract README section above are relevant to that project's source code only.