Chore: minor changes

This commit is contained in:
SukkaW
2023-11-17 21:36:09 +08:00
parent f88c3648a2
commit a5e36a1cd8
10 changed files with 51 additions and 50 deletions

View File

@@ -18,6 +18,12 @@ const traceAsync = async <T>(prefix: string, fn: () => Promise<T>): Promise<T> =
};
export { traceAsync };
export interface TaskResult {
readonly start: number;
readonly end: number;
readonly taskName: string;
}
const task = <T>(__filename: string, fn: () => Promise<T>, customname: string | null = null) => {
const taskName = customname ?? path.basename(__filename, path.extname(__filename));
return async () => {
@@ -27,7 +33,7 @@ const task = <T>(__filename: string, fn: () => Promise<T>, customname: string |
const end = performance.now();
console.log(`✅ [${taskName}] Executed successfully: ${(end - start).toFixed(3)}ms`);
return { start, end, taskName } as const;
return { start, end, taskName } as TaskResult;
};
};
export { task };