Polyfill Promise.withResolvers
Fixes: https://gitlab.com/soapbox-pub/soapbox/-/issues/1802
This commit is contained in:
parent
39065bc1af
commit
715c961fff
|
@ -1,3 +1,5 @@
|
|||
import 'soapbox/polyfill/Promise.withResolvers.ts';
|
||||
|
||||
import { enableMapSet } from 'immer';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
if (!Promise.withResolvers) {
|
||||
Promise.withResolvers = function withResolvers<T>(): PromiseWithResolvers<T> {
|
||||
|
||||
let resolve: (value: T | PromiseLike<T>) => void;
|
||||
let reject: (reason?: any) => void;
|
||||
|
||||
const promise = new this<T>((_resolve, _reject) => {
|
||||
resolve = _resolve;
|
||||
reject = _reject;
|
||||
});
|
||||
|
||||
return { resolve: resolve!, reject: reject!, promise };
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue