polyfill.ts 352 B

123456789101112131415
  1. if (typeof Promise.withResolvers !== 'function') {
  2. Promise.withResolvers = function <T>() {
  3. let resolve!: (value: T | PromiseLike<T>) => void;
  4. let reject!: (reason?: any) => void;
  5. const promise = new Promise<T>((res, rej) => {
  6. resolve = res;
  7. reject = rej;
  8. });
  9. return { promise, resolve, reject };
  10. };
  11. }
  12. export {};