base: prevent infinite loop

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/783/head
Varun Patil 2023-08-20 23:34:15 -07:00
parent dca914274c
commit 2f4fff2ff8
1 changed files with 2 additions and 0 deletions

View File

@ -154,6 +154,8 @@ async function getFilesInternal(fileIds: number[]): Promise<IFileInfo[]> {
* @returns Generator of lists of results. Each list is of length n.
*/
export async function* runInParallel<T>(promises: (() => Promise<T>)[], n: number) {
if (!promises.length) return;
promises.reverse(); // reverse so we can use pop() efficiently
const results: T[] = [];