Skip to content

Instantly share code, notes, and snippets.

@leumasme
Created October 6, 2021 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leumasme/d642fa4966891b3bedcabcf11df4666d to your computer and use it in GitHub Desktop.
Save leumasme/d642fa4966891b3bedcabcf11df4666d to your computer and use it in GitHub Desktop.
Promise.fulfilled polyfill, to check if a Promise was completed
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