timeandreturn
Version:
Get the elapsed time of a block of code and return the result of that block of code.
13 lines • 483 B
TypeScript
/**
* Call callback with the time taken to run block, and return the result of block
*
* If block returns a Promise, call callback after promise resolves.
*
* Elapsed time is given in milliseconds.
*/
export declare function timeAndReturn<T>(callback: (elapsedTime: number) => void, block: () => T): T;
/**
* Log the time taken to run block, and return the result of block
*/
export declare function logTimeAndReturn<T>(block: () => T): T;
//# sourceMappingURL=index.d.ts.map