I hereby claim:
- I am maartenbusstra on github.
- I am maartenbusstra (https://keybase.io/maartenbusstra) on keybase.
- I have a public key whose fingerprint is DE19 14FD E115 1C11 C080 D5F9 99DD 44BE 8431 FE3B
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const batchedMap = batchSize => data => async (fn) => { | |
const batches = data.length / batchSize; | |
let result = []; | |
for (let i = 0; i < batches; i++) { | |
const res = await Promise.all(data | |
.slice(i * batchSize, (i + 1) * batchSize) | |
.map((d, j) => fn(d, (i * batchSize) + j)), | |
); | |
result = result.concat(res); | |
} |