refactor: sendtime/join time

This commit is contained in:
手瓜一十雪
2024-07-25 10:32:44 +08:00
parent 3bb349e20a
commit 85b176ab79
4 changed files with 51 additions and 23 deletions

View File

@@ -18,9 +18,8 @@ export function PromiseTimer<T>(promise: Promise<T>, ms: number): Promise<T> {
);
return Promise.race([promise, timeoutPromise]);
}
export async function runAllWithTimeout<T>(tasks: Promise<T>[], timeout: number): Promise<T[]> {
const wrappedTasks = tasks.map(task =>
const wrappedTasks = tasks.map(task =>
PromiseTimer(task, timeout).then(
result => ({ status: 'fulfilled', value: result }),
error => ({ status: 'rejected', reason: error })