find value for deep nested keys
$ npm install --save deep-find
var deepFind = require('deep-find');
var obj = {
employee:{
name: {
first: 'yash',
last: 'singh'
}
}
}
deepFind(obj, 'employee.name.first');
var deepFind = require('deep-find');
pass array as argument
var deepFind = require('deep-find');
var obj = {
employees: [{
name: {
first: 'yash',
last: 'singh'
}
}, {
name: {
first: 'ruby',
last: 'singh'
}
}]
}
var value = deepFind(obj, ['employees[0]', 'name', 'first']);
pass string as argument
var deepFind = require('deep-find');
var obj = {
employees: [{
name: {
first: 'yash',
last: 'singh'
}
}, {
name: {
first: 'ruby',
last: 'singh'
}
}]
}
var 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