Skip to content

Instantly share code, notes, and snippets.

@aleksejkozin
Last active January 6, 2021 17:10
Show Gist options
  • Save aleksejkozin/b7b7ddcabfffdb784cdf0f0f8ce096f9 to your computer and use it in GitHub Desktop.
Save aleksejkozin/b7b7ddcabfffdb784cdf0f0f8ce096f9 to your computer and use it in GitHub Desktop.
const call = async <T>(fn: Promise<T> | (() => T)): Promise<void> => {
if (typeof fn === 'function') {
fn()
} else {
await fn
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment