Created
October 21, 2018 16:16
-
-
Save sethdavis512/0b2a38a0e3f190928e114d83a72d9fee to your computer and use it in GitHub Desktop.
This file contains hidden or 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 flattenFilePath = (pathPart, directoryOrFileContents) => { | |
return Object.entries(directoryOrFileContents).reduce((flattenedFilePaths, [key, value]) => { | |
if (typeof value === "object") { | |
Object.assign(flattenedFilePaths, flattenFilePath(`${pathPart}/${key}`, value)) | |
} else { | |
flattenedFilePaths[`${pathPart}/${key}`] = value | |
} | |
return flattenedFilePaths | |
}, {}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment