Created
September 3, 2019 09:20
-
-
Save coreequip/0d8747d8e31fcb64ce98598842a85206 to your computer and use it in GitHub Desktop.
ECMAScript Defer Pattern
This file contains 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.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