async function processData(data, process, chunkSize, delay) {
let i = -1;
for (const n of data) {
if (++i === chunkSize) {
i = 0;
await new Promise(r => setTimeout(r, delay));
}
process(n);
}
}
processData(Array(10).keys(), console.log, 3, 1500).then(() => console.log('DONE'));