mini-defer
v0.0.5
Published
Tiny module for creating a deferred with no polyfilling
Downloads
1,458
Maintainers
Readme
mini-defer
Tiny module for creating a deferred with no polyfilling
Made with ❤ at @outlandish
Install
npm install mini-defer --save
ES6 Import (w/ Babel)
import defer from 'mini-defer'
CommonJS Require
var defer = require('mini-defer')
Script
<script src="/node_modules/mini-defer/index.js"></script>
typeof window.miniDefer //=> "Function"
Usage
defer() : Object
Create a deferred.
Example
function operation ()
const deferred = defer()
const eventBasedOperation = doOperation()
eventBasedOperation.onsuccess = deferred.resolve
eventBasedOperation.onerror = deferred.reject
return deferred.promise
}
Contributing
All pull requests and issues welcome!
If you're not sure how, check out Kent C. Dodds' great video tutorials on egghead.io!