Skip to content

Instantly share code, notes, and snippets.

@coreequip
Created September 3, 2019 09:20
Show Gist options
  • Save coreequip/0d8747d8e31fcb64ce98598842a85206 to your computer and use it in GitHub Desktop.
Save coreequip/0d8747d8e31fcb64ce98598842a85206 to your computer and use it in GitHub Desktop.
ECMAScript Defer Pattern
Promise.defer = function () {
return (_ => {
let resolve, reject
let p = new Promise((res, rej) => {
resolve = res
reject = rej
})
return {promise: p, reject, resolve}
})()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment