Recursive Entries
Object.entries, but recursively ;)
Installation
npm i recursive-entries
Usage
const {recursiveEntries, valueFromPath} = require('recursive-entries');
Pro-tip: Utilize the test file as an example
Documentation
recursiveEntries(obj)
- where
objis any vanilla object - returns an array of length 2 arrays, where the first item is an array of keys leading to the value and the second item is the value found at the end of the path; for example,
[ [["path", "to"], "value"], ... ]
valueFromPath(obj, path)
- where
objis any vanilla object - where
pathis an array of keys - returns value found at the end of the path
- returns
undefinedif the path does not exist
Engineered with by @EthanThatOneKid