Snippets Collections
const recurse = (rows) => _.map((rows), (row) => row.collapsed ? [row] : [row, recurse(row.children)]);

const flattenTree = tree => _.flattenDeep(recurse(tree));

const mostLikes = (array) => {
  const authorsAndLikesArray = _(array)
    .groupBy("author")
    .map((objs, key) => ({
      author: key,
      totalLikes: _.sumBy(objs, "likes"),
    }))
    .value();
  const sorted = _.sortBy(authorsAndLikesArray, "totalLikes").reverse();
  return sorted
};
star

Sat Aug 27 2022 13:26:17 GMT+0000 (Coordinated Universal Time)

#lodash #javascript #flatten
star

Tue Apr 12 2022 23:58:23 GMT+0000 (Coordinated Universal Time)

#javascript #lodash

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension