Skip to content

Instantly share code, notes, and snippets.

@JeffML
Created October 30, 2017 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffML/1bbe228f271765d3ee3a917196e8a81c to your computer and use it in GitHub Desktop.
Save JeffML/1bbe228f271765d3ee3a917196e8a81c to your computer and use it in GitHub Desktop.
Reduces treeize data
if (useMethod === 'treeizedReduced') {
var rs = treeized(resultSet)
const rsr = rs.reduce((o, r) => {
const rc = r.categories.reduce((oo, c) => {
oo[c.type] = {
titles: c.titles.map(t => t.name)
}
return oo;
}, {})
o[r.name] = {
categories: rc
};
return o;
}, {});
console.log(JSON.stringify({
treeizedReduced: rsr
}, null, 4));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment