find value for deep nested keys
$ npm install --save deep-find
var deepFind = require('deep-find');
var obj = {
employee:{
name: {
first: 'Jack',
last: 'Daniels'
}
}
}
deepFind(obj, 'employee.name.first');
var deepFind = require('deep-find');
pass array as argument
const deepFind = require('deep-find');
const obj = {
employees: [{
name: {
first: 'Jack',
last: 'Daniels'
}
}, {
name: {
first: 'Milli',
last: 'Daniels'
}
}]
}
const value = deepFind(obj, ['employees[0]', 'name', 'first']);
pass string as argument
const deepFind = require('deep-find');
const obj = {
employees: [{
name: {
first: 'Jack',
last: 'Daniels'
}
}, {
name: {
first: 'Milli',
last: 'Daniels'
}
}]
}
const value = deepFind(obj, 'employees[0].name.first');
npm test
node benchmark.js
regular search x 1,212,008 ops/sec ±1.61% (81 runs sampled)
For bugs and feature requests, please create an issue.
MIT © Yashprit Singh