Add Promise.withResolvers Polyfill
Author: pckilgoreCreated Jun 13, 2024Updated Jul 19, 2024
What
Missing Promise.withResolvers
Details
react-pdf recently upgraded and no longer includes a polyfill for this API, which is now baseline available in 2024.
We've got some older safari clients breaking.
Happy to make a PR:
ref: CoreJS Polyfill
Code roughly:
if (typeof Promise.withResolvers === 'undefined') {
window.Promise.withResolvers = function () {
let resolve, reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
return { promise, resolve, reject };
}
}Source: polyfillpolyfill/polyfill-service