Files
openclaw/src/utils/chunk-items.ts
Peter Steinberger 1e7510ae10 docs: continue inline comment pass (#88849)
Adds broad inline comments and JSDoc for CLI, cron, outbound/channel, plugin SDK, ACP, shared helpers, net policy, and related utility contracts. Proof: git diff --check on latest exact head plus focused cron tests passed; CI had no failing checks observed before merge attempt.
2026-05-31 22:32:28 -04:00

12 lines
373 B
TypeScript

/** Splits items into fixed-size chunks, preserving order and returning one row for non-positive sizes. */
export function chunkItems<T>(items: readonly T[], size: number): T[][] {
if (size <= 0) {
return [Array.from(items)];
}
const rows: T[][] = [];
for (let i = 0; i < items.length; i += size) {
rows.push(items.slice(i, i + size));
}
return rows;
}