Created
April 19, 2018 14:21
-
-
Save tuor4eg/74a4e90808634d5000fc31c74ce7f5bb 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
export const sortDeps = (keys, packetList) => { | |
const keyRed = keys.reduce((acc, element) => { | |
if (packetList[element] instanceof Array && packetList[element].length === 0 || !packetList[element]) { | |
return [...acc, element]; | |
} | |
return [...acc, ...sortDeps(packetList[element], packetList), element]; | |
}, []); | |
return keyRed; | |
}; | |
export default (obj) => Array.from(new Set(sortDeps(Object.keys(obj), obj))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment