findkeys
v1.0.1
Published
Simple and blazing fast object keys locator.
Downloads
2
Maintainers
Readme
findkeys
A simple and blazing fast object keys locator ✨
Sometimes it happens that we have a very big object with a lot of keys, like a response to a http request for example. Findkeys is a small utility module, able to search such an object and return paths to keys of interest. Supports all javascript types. ES5 and ES6 compatible.
Install
npm:
npm install findkeys
yarn:
yarn add findkeys
Usage
let obj = {
user: {
city: 'Paderborn',
country: 'Germany',
datas: {
firstname: 'John',
lastname: 'Doe'
},
children: [
{
firstname: 'Lisa',
lastname: 'Doe'
},
{
firstname: 'Bryan',
lastname: 'Doe'
}
]
}
}
const { findkeys } = require('findkeys')
// import { findkeys } from 'findkeys'
let res = findkeys(obj, ['firstname', 'country'])
// [root.user.country, root.user.datas.firstname, root.user.children.0.firstname, root.user.children.1.firstname]
console.log(res)
License
MIT © Melkis Hengue