Created
December 11, 2019 22:28
-
-
Save bholloway/fdfbd4d80f79b115d8a34f9eb3f4503c to your computer and use it in GitHub Desktop.
visitor for webpack stat groups
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 walk = (text) => (v) => { | |
if (Array.isArray(v)) { | |
return walk(text)({ groups: v }); | |
} else { | |
const { label, path, gzipSize, groups } = v; | |
if (label && label.includes(text)) { | |
return [{label, path, gzipSize}]; | |
} else if (groups && groups.length) { | |
return groups.map(walk(text)).reduce((r, v) => r.concat(v), []); | |
} else { | |
return []; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment