ProvenPin Install

lodash-es collection transform helpers: working versions (tested 2026-10-15)

Shape nested data with lodash-es groupBy, keyBy, pick, uniqBy and orderBy for a small reporting pipeline offline.

passed1 passed · 0 failed2026-10-15 16:01 UTC
Status
passed
Last passed
2026-10-15 16:01 UTC
Tests
1 / 1
Language
TypeScript
Runtime
node v22.23.3
pinned versions3
lodash-es@4.18.1@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38764699834

The code

Exactly the files that passed. Your agent can pull them with get_recipe("lodash-es-collection-helpers") (install), or see them on GitHub.

package.json
{
  "name": "lodash-es-collection-helpers",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {"lodash-es":"4.18.1"},
  "devDependencies": {"@types/node":"26.6.5","tsx":"4.23.15"}
}
src/report.ts
import { groupBy, keyBy, orderBy, pick, sumBy, uniqBy } from "lodash-es";

export type Row = { id: string; region: string; sku: string; qty: number; price: number };

export function summarize(rows: Row[]) {
  const unique = uniqBy(rows, "id");
  const byRegion = groupBy(unique, "region");
  const totals = Object.fromEntries(
    Object.entries(byRegion).map(([region, items]) => [
      region,
      sumBy(items, (r) => r.qty * r.price),
    ]),
  );
  const top = orderBy(unique, [(r) => r.qty * r.price], ["desc"]).slice(0, 3);
  const index = keyBy(unique, "id");
  return {
    totals,
    top: top.map((r) => pick(r, ["id", "sku", "qty", "price"])),
    get: (id: string) => index[id],
  };
}
test/report.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { summarize, type Row } from "../src/report.ts";

const rows: Row[] = [
  { id: "1", region: "west", sku: "A", qty: 2, price: 10 },
  { id: "1", region: "west", sku: "A", qty: 2, price: 10 },
  { id: "2", region: "east", sku: "B", qty: 5, price: 3 },
  { id: "3", region: "west", sku: "C", qty: 1, price: 50 },
];

test("dedupes and totals by region", () => {
  const report = summarize(rows);
  assert.deepEqual(report.totals, { west: 70, east: 15 });
  assert.equal(report.top[0].sku, "C");
  assert.equal(report.get("2")?.sku, "B");
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.