Skip to content

Instantly share code, notes, and snippets.

@intrnl
Last active Aug 12, 2021
Embed
What would you like to do?
type Callable = (...args: any[]) => any;
export function attempt<T extends Callable>(fn: T, ...args: Parameters<T>): Promise<ReturnType<T>> {
return new Promise((resolve) => fn(...args));
}
function attempt (fn, ...args) {
return new Promise((resolve) => resolve(fn(...args)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment