deeper-key
v1.0.3
Published
Vanilla JS object utility for working with complex JavaScript objects
Downloads
32
Maintainers
Readme
deeper-key
Vanilla JS object utility for working with complex JavaScript objects
Features
- method to get all keys from a given object
- method to return bool whether given key exists in a given object
- method to return an array of all values for a given key in a given object
Installation
$ npm install deeper-key
Usage
let { deepKeys, deepExists, deepValues } = require('deeper-key')
deepKeys
let testData = {
results: {
success: true,
nestedResults: {
success: true,
numbers: [1,2,3,4],
deeplyNestedResults: {
success: true
},
randomErrors: ['something went wrong']
}
}
};
let allKeys = deepKeys(testData);
//=> ['results', 'success', 'nestedResults', 'success', 'numbers', 'deeplyNestedResults', 'success']
deepValues
let allValues = deepValues(testData, 'randomErrors');
//=> ['something went wrong']
deepExists
let keyExists = deepExists(testData, 'deeplyNestedResults');
//=> true