24 lines
579 B
TypeScript
24 lines
579 B
TypeScript
export async function logStep<T = void>(
|
|
inProgressText: string,
|
|
step: () => Promise<T> | T,
|
|
): Promise<T>;
|
|
export async function logStep<T = void>(
|
|
inProgressText: string,
|
|
step: () => Promise<T> | T,
|
|
doneText: string,
|
|
): Promise<T>;
|
|
|
|
export async function logStep<T = void>(
|
|
inProgressText: string,
|
|
step: () => Promise<T> | T,
|
|
doneText: string = `Completed step "${inProgressText}"`,
|
|
) {
|
|
console.time(doneText);
|
|
console.log(`${inProgressText}...`);
|
|
|
|
return Promise.resolve(step()).then((value) => {
|
|
console.timeEnd(doneText);
|
|
return value;
|
|
});
|
|
}
|