Skip to content

Instantly share code, notes, and snippets.

View ZiuChen's full-sized avatar
🎯
Focusing

Ziu ZiuChen

🎯
Focusing
View GitHub Profile
@lmammino
lmammino / promise-with-resolvers-polyfill.js
Created July 18, 2023 17:57
Promise.withResolvers() polyfill
if (typeof Promise.withResolvers === 'undefined') {
Promise.withResolvers = function () {
let resolve, reject
const promise = new Promise((res, rej) => {
resolve = res
reject = rej
})
return { promise, resolve, reject }
}
}