Created
April 2, 2018 10:39
-
-
Save akabab/6c8be6a833657c1b0259c74f3f015f72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const flatKeys = (object, keys = [], k = '') => { | |
for (const key in object) { | |
const rest = k.length ? '.' + key : key | |
if (typeof object[key] === 'object' && !Array.isArray(object[key])) { | |
flatKeys(object[key], keys, k + rest) | |
} else { | |
keys.push(k + rest) | |
} | |
} | |
return keys | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment