-
-
Save kvasdopil/f2a2773e4a4d4540538ed2a5d4ee7ac8 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 countSize = (node) => { | |
reduce((size, element) => { | |
if (element.type === 'file') { | |
return (size + element.meta.size); | |
} | |
return size; | |
}, node, 0); | |
export default (tree) => { | |
const duIt = tree | |
.children | |
.map(element => [element.name, countSize(element)]) | |
.sort((a, b) => a[1] - b[1]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment