Fix database closed multiple times.

utt part support Ctrl + C
This commit is contained in:
2023-05-23 10:50:56 +08:00
parent 144797f246
commit 5c9712a02c
6 changed files with 69 additions and 12 deletions

View File

@@ -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]);
}
}