Created
March 7, 2023 21:18
-
-
Save robindiddams/88fd5447273ae6db969ac8127bb44f15 to your computer and use it in GitHub Desktop.
Promise wrapper that logs the time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const timePromise = <T>(p: Promise<T>, name: string): Promise<T> => { | |
const start = Date.now(); | |
return p.then((res) => { | |
console.log(name, 'took', Date.now() - start); | |
return res; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment