refactor(utils): share chunkItems helper

This commit is contained in:
Peter Steinberger
2026-02-16 01:52:30 +00:00
parent 618008b483
commit 19f53543d2
3 changed files with 12 additions and 22 deletions

10
src/utils/chunk-items.ts Normal file
View File

@@ -0,0 +1,10 @@
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;
}