@util-funcs/object-get
v0.0.2
Published
Deep dive into plain object and take value by key chaining.
Downloads
46
Maintainers
Readme
object-get
Deep dive into plain object and take value by key chaining.
Getting Started
import get from '@util-funcs/object-get';
Installing
npm i @util-funcs/object-get --save
or
yarn add @util-funcs/object-get
Examples
const data = {
name: 'John',
surname: 'Doe',
age: 34,
location: {
city: 'Londra',
country: 'UK',
},
orders: [
{
name: 'Headphone',
price: 45.6,
type: 'electronic',
},
{
name: 'Macbook Air 13.3 inch',
price: 45.6,
type: 'electronic',
},
],
'#hobbies': ['travel', 'edm'],
};
get('name', data)) === 'John'
get('location.city', data) === 'Londra'
get('#hobbies[0]', data) === 'travel'
get('orders[0]name', data) === 'Headphone'
get('orders[0]name.length', data) === 9
get('orders[0]category', data, 'uncategorized') === 'uncategorized'
Run tests
npm test
Built With
Versioning
We use SemVer for versioning.
Authors
- Ahmet ATAY - Initial work
License
This project is licensed under the MIT License - see the LICENSE.md file for details