Typescript all the parser things

This commit is contained in:
Thaum Rystra
2024-02-20 23:21:12 +02:00
parent 3ea492ee78
commit ac15512bc5
86 changed files with 926 additions and 718 deletions

View File

@@ -0,0 +1,19 @@
/**
* Async compatible map that processes all items in parallel
*/
export async function parallelMap(array: any[], fn: (doc: any) => Promise<any>): Promise<any[]> {
return await Promise.all(array.map(fn));
}
/**
* Async compatible map that processes all items in series
*/
export async function serialMap(array: any[], fn: (doc: any) => Promise<any>): Promise<any[]> {
const results: any[] = [];
for (const doc of array) {
const result = await fn(doc);
results.push(result);
}
return results;
}