https://github.com/sdgluck/mini-defer
:tada: Tiny module for creating a deferred with no polyfilling
https://github.com/sdgluck/mini-defer
Last synced: 9 months ago
JSON representation
:tada: Tiny module for creating a deferred with no polyfilling
- Host: GitHub
- URL: https://github.com/sdgluck/mini-defer
- Owner: sdgluck
- License: mit
- Created: 2016-02-29T09:44:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-16T16:49:27.000Z (over 9 years ago)
- Last Synced: 2024-08-10T23:16:25.955Z (almost 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mini-defer
> Tiny module for creating a deferred with no polyfilling
Made with ❤ at [@outlandish](http://www.twitter.com/outlandish)
[](http://standardjs.com/)
## Install
npm install mini-defer --save
Exported using UMD pattern, otherwise available on `window` as `miniDefer`.
## 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](https://egghead.io/lessons/javascript-identifying-how-to-contribute-to-an-open-source-project-on-github)!