mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 01:47:27 +00:00
refactor(utils): share chunkItems helper
This commit is contained in:
10
src/utils/chunk-items.ts
Normal file
10
src/utils/chunk-items.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user