mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-07-08 01:31:00 +08:00
Fix database closed multiple times.
utt part support Ctrl + C
This commit is contained in:
15
utils.ts
15
utils.ts
@@ -90,3 +90,18 @@ export async function asyncFilter<T>(
|
||||
)).filter((i) => i !== fail);
|
||||
return t.map((t) => t[0]);
|
||||
}
|
||||
|
||||
export async function asyncForEach<T, V>(
|
||||
arr: ArrayLike<T>,
|
||||
callback: (
|
||||
this: V | undefined,
|
||||
element: T,
|
||||
index: number,
|
||||
array: ArrayLike<T>,
|
||||
) => Promise<void>,
|
||||
thisArg?: V,
|
||||
) {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
await callback.apply(thisArg, [arr[i], i, arr]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user