Gets the value at
path
ofobject
(with an optionaldefault
)
npm install fast-get
This module can be used for Node.js as well as browsers using Browserify.
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'
npm test
npm run benchmark
Size (uglify + gzip) | Performance | |
---|---|---|
fast-get | 159 bytes | 555,897 ops/sec |
lodash.get | 2,145 bytes | 206,432 ops/sec |
MIT