Files
2026-04-30 23:39:28 -07:00

11 lines
374 B
TypeScript

export type ExportLimitState = {
sourceArtifacts: number;
};
export function reserveExportInputs<T>(inputs: T[], state: ExportLimitState, limit: number | null) {
const remaining = limit === null ? inputs.length : Math.max(0, limit - state.sourceArtifacts);
const reserved = inputs.slice(0, remaining);
state.sourceArtifacts += reserved.length;
return reserved;
}