Open lionel-rowe opened 3 months ago
function chunk(input, size) { return Object.values( Object.groupBy(input, (_, i) => Math.floor(i / size)) ); } function countBy(input, fn) { return Object.fromEntries( Object.entries(Object.groupBy(input, fn)).map(([k, v]) => [k, v.length]) ); } function partition(input, fn) { const results = Object.groupBy(input, (x) => Boolean(fn(x))) return [results.true ?? [], results.false ?? []] }