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