import chunk from "lodash/chunk" ; export async function promiseAllChunks < T = any > ( callbacks , chunkSize = 3 ) { let results = [ ] ; const chunks = chunk ( callbacks , chunkSize ) ; for ( let i = 0 ; i < chunks . length ; i ++ ) { results = results . concat ( await Promise . all ( chunks [ i ] . map ( ( cb ) => cb ( ) ) ) ) ; } return results ; }