ProvenPin Install

Remeda pipe, groupBy and typed data helpers: working versions (tested 2026-10-15)

Transform collections with Remeda pipe, map, filter, groupBy and sumBy while keeping TypeScript inference, covering a small analytics pipeline in Node tests.

passed2 passed · 0 failed2026-10-15 16:04 UTC
Status
passed
Last passed
2026-10-15 16:04 UTC
Tests
2 / 2
Language
TypeScript
Runtime
node v22.23.3
pinned versions3
remeda@2.52.0@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("remeda-pipe-data") (install), or see them on GitHub.

package.json
{
  "name": "remeda-pipe-data",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "remeda": "2.52.0"
  },
  "devDependencies": {
    "@types/node": "26.6.5",
    "tsx": "4.23.15"
  }
}
src/stats.ts
import * as R from "remeda";

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

export function revenueByRegion(sales: Sale[]) {
  return R.pipe(
    sales,
    R.filter((s) => s.qty > 0),
    R.groupBy((s) => s.region),
    R.mapValues((rows) => R.sumBy(rows, (s) => s.qty * s.price)),
  );
}

export function topSkus(sales: Sale[], n: number) {
  return R.pipe(
    sales,
    R.groupBy((s) => s.sku),
    R.mapValues((rows) => R.sumBy(rows, (s) => s.qty)),
    R.entries(),
    R.sortBy([([, qty]) => qty, "desc"]),
    R.take(n),
    R.map(([sku, qty]) => ({ sku, qty })),
  );
}
test/stats.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { revenueByRegion, topSkus, type Sale } from "../src/stats.ts";

const sales: Sale[] = [
  { sku: "A", region: "west", qty: 2, price: 10 },
  { sku: "A", region: "east", qty: 1, price: 10 },
  { sku: "B", region: "west", qty: 5, price: 3 },
  { sku: "C", region: "east", qty: 0, price: 99 },
];

test("revenue by region ignores zero qty", () => {
  assert.deepEqual(revenueByRegion(sales), { west: 35, east: 10 });
});

test("top skus by quantity", () => {
  assert.deepEqual(topSkus(sales, 2), [{ sku: "B", qty: 5 }, { sku: "A", qty: 3 }]);
});

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.