geninq
Version:
A JavaScript version of the Linq library for Generators
20 lines (18 loc) • 421 B
text/typescript
import "./aggregate";
import { It } from "../test-utils";
It("aggregates a basic", (g) => g.aggregate((c, n) => c + n), 6);
It(
"aggregates an accumulator",
(g) => g.aggregate({}, (c, n) => ({ ...c, [n]: n })),
{ 1: 1, 2: 2, 3: 3 }
);
It(
"aggregates a selector",
(g) =>
g.aggregate(
{} as any,
(c, n) => ({ ...c, [n]: n }),
(p) => ({ ...p, 4: 4 })
),
{ 1: 1, 2: 2, 3: 3, 4: 4 }
);