export function chunk<T>(items: readonly T[], size: number): T[][] {
if (size < 1) throw new Error('chunk size must be >= 1');
const out: T[][] = [];
for (let i = 0; i < items.length; i += size) {
out.push(items.slice(i, i + size));
}
return out;
}
chunk([1, 2, 3, 4, 5, 6, 7], 3); // [[1,2,3], [4,5,6], [7]]
// Bulk-send in batches of 50:
for (const batch of chunk(allRows, 50)) {
await fetch('/api/bulk', { method: 'POST', body: JSON.stringify(batch) });
}
Create a free account and build your private vault. Share publicly whenever you want.