Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/melkishengue/findkeys
A simple and blazing fast object keys locator
https://github.com/melkishengue/findkeys
Last synced: 11 days ago
JSON representation
A simple and blazing fast object keys locator
- Host: GitHub
- URL: https://github.com/melkishengue/findkeys
- Owner: melkishengue
- License: mit
- Created: 2020-11-11T16:06:01.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-13T01:40:11.000Z (almost 4 years ago)
- Last Synced: 2024-10-30T14:02:31.300Z (13 days ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-blazingly-fast - findkeys - A simple and blazing fast object keys locator (JavaScript)
README
# findkeys
[![Build Status](https://travis-ci.org/melkishengue/findkeys.svg?branch=master)](https://travis-ci.org/melkishengue/findkeys) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
**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
```javascript
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