1 | // Returns ALL of an object's keys (even nested ones) as an array of dot notation.
|
2 | const isObject = require('./is-object')
|
3 |
|
4 | function objectDeepKeys(obj) {
|
5 | if (!isObject(obj)) return []
|
6 |
|
7 | return Object.keys(obj)
|
8 | .filter(key => isObject(obj[key]))
|
9 | .map(key => objectDeepKeys(obj[key]).map(k => `${key}.${k}`))
|
10 | .reduce(
|
11 | (x, y) => x.concat(y),
|
12 | Object.keys(obj).filter(key => !isObject(obj[key]))
|
13 | )
|
14 | }
|
15 |
|
16 | module.exports = objectDeepKeys
|