Initial move

This commit is contained in:
2024-09-03 14:50:33 +02:00
parent adb6be0006
commit 9fa656ed5e
138 changed files with 13117 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
export class ChunkProcessor<T> {
private chunkSize: number;
constructor(chunkSize: number = 1000) {
this.chunkSize = chunkSize;
}
async processArray(array: T[], callback: (chunk: T[]) => void): Promise<void> {
const totalChunks = Math.ceil(array.length / this.chunkSize);
for (let i = 0; i < totalChunks; i++) {
const chunk = array.slice(i * this.chunkSize, (i + 1) * this.chunkSize);
await this.processChunk(chunk, callback);
}
}
private async processChunk(chunk: T[], callback: (chunk: T[]) => void): Promise<void> {
return new Promise<void>((resolve) => {
setTimeout(() => {
callback(chunk);
resolve();
}, 0);
});
}
}