1// Like allPromCalls but limits concurrency to batchSize (default 10) 2// If shouldStop returns true for any result, stops processing remaining batches 3export const batchPromCalls = async <T, R>( 5 fnc: (item: T) => Promise<R>, 7 shouldStop?: (result: R) => boolean 9 const results: R[] = [] 10 for (let i = 0; i < data.length; i += batchSize) { 11 const batch = data.slice(i, i + batchSize) 12 const batchResults = await Promise.all(batch.map(fnc)) 13 results.push(...batchResults) 14 if (shouldStop && batchResults.some(shouldStop)) break