Takes an async function and wraps it in promise that rejects if the original function takes longer to resolve than a specific amount of time in milliseconds. If the original function resolves before the timeout, that value is returned.
withTimeout<T extends AsyncFunc>(
asyncFunction: T,
timeout: number
): (...args: Parameters<T>) => Promise<UnwrapPromiseOrResult<T>>