export function withResolvers<T, P extends PromiseLike<T> = PromiseLike<T>>() {
  let resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void;
  const promise = new Promise<T>((res, rej) => {
    resolve = res;
    reject = rej;
  }) as unknown as P;
  // @ts-ignore
  return { promise, resolve, reject };
}