// Polyfill for the `Promise.withResolvers` API: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers // // Once `Promise.withResolvers` hits widely available, we should remove this // polyfill in favor of that API. /** @internal */ export function promiseWithResolvers() { let resolve!: (value: T | PromiseLike) => void; let reject!: (reason?: any) => void; const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); return { promise, resolve, reject }; }