Skip to content

Instantly share code, notes, and snippets.

@bholloway
Created December 11, 2019 22:28
Show Gist options
  • Save bholloway/fdfbd4d80f79b115d8a34f9eb3f4503c to your computer and use it in GitHub Desktop.
Save bholloway/fdfbd4d80f79b115d8a34f9eb3f4503c to your computer and use it in GitHub Desktop.
visitor for webpack stat groups
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