function splitIntoGroups
splitIntoGroups(
files: string[],
groupCount: number,
timings: Record<string, number>
): Promise<{ groups: string[][]; weights: Map<string, number>; }>

Packs files into groupCount groups of roughly equal estimated duration, returning the groups and the per-file weights the estimate used (the caller reuses them to apportion wall time).

const timings = { '/a.ts': 300, '/b.ts': 200, '/c.ts': 100 };
const { groups, weights } = await splitIntoGroups(['/a.ts', '/b.ts', '/c.ts'], 2, timings);
groups; // [['/a.ts'], ['/b.ts', '/c.ts']] — LPT keeps totals balanced (300 vs 300)
weights.get('/a.ts'); // 300

Parameters

files: string[]
groupCount: number
timings: Record<string, number>

Return Type

Promise<{ groups: string[][]; weights: Map<string, number>; }>

Usage

import { splitIntoGroups } from "lib/commands/test/grouping.ts";