fast-get
v1.0.5
Published
Gets the value at `path` of `object` (with an optional `default`)
Downloads
1,213
Readme
fast-get
Gets the value at
path
ofobject
(with an optionaldefault
)
Install
npm install fast-get
This module can be used for Node.js as well as browsers using Browserify.
Usage
const _get = require('fast-get')
const object = {a: [{b: {c: 3}}]}
_get(object, 'a[0].b.c')
// => 3
_get(object, ['a', '0', 'b', 'c'])
// => 3
_get(object, 'a.b.c', 'default')
// => 'default'
Tests
npm test
Benchmark
npm run benchmark
| | Size (uglify + gzip) | Performance (array) | Performance (string) | |------------|----------------------|---------------------|----------------------| | fast-get | 220 bytes | 612,000 ops/sec | 571,000 ops/sec | | lodash.get | 2,145 bytes | 810,000 ops/sec | 200,000 ops/sec |
Licence
MIT