Created
October 6, 2021 10:06
-
-
Save leumasme/d642fa4966891b3bedcabcf11df4666d to your computer and use it in GitHub Desktop.
Promise.fulfilled polyfill, to check if a Promise was completed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Promise = new Proxy(Promise, { | |
construct(target, args) { | |
let p = new target(...args) | |
p.fulfilled = false; | |
p.then(()=>p.fulfilled = true) | |
p.catch(()=>p.fulfilled = true) | |
return p; | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment