Skip to content

Instantly share code, notes, and snippets.

@robindiddams
Created March 7, 2023 21:18
Show Gist options
  • Save robindiddams/88fd5447273ae6db969ac8127bb44f15 to your computer and use it in GitHub Desktop.
Save robindiddams/88fd5447273ae6db969ac8127bb44f15 to your computer and use it in GitHub Desktop.
Promise wrapper that logs the time
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