Tiny module for creating a deferred with no polyfilling
Made with ❤ at @outlandish
npm install mini-defer --save
Exported using UMD pattern, otherwise available on window
as miniDefer
.
defer() : Object
Create a deferred.
function operation ()
const deferred = defer()
const eventBasedOperation = doOperation()
eventBasedOperation.onsuccess = deferred.resolve
eventBasedOperation.onerror = deferred.reject
return deferred.promise
}
All pull requests and issues welcome!
If you're not sure how, check out Kent C. Dodds' great video tutorials on egghead.io!