https://github.com/lightsofapollo/co-promise
Wrapper for co so it returns promises not thunks
https://github.com/lightsofapollo/co-promise
Last synced: 8 months ago
JSON representation
Wrapper for co so it returns promises not thunks
- Host: GitHub
- URL: https://github.com/lightsofapollo/co-promise
- Owner: lightsofapollo
- License: mit
- Created: 2014-05-07T21:21:35.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-01-28T06:17:51.000Z (over 11 years ago)
- Last Synced: 2025-01-28T19:49:08.697Z (over 1 year ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# co-promise
This does what you would expect and brings co a lot closer to what the
async function proposal for es7 does.
```js
var co = require('co-promise');
co(function* (err, value) {
}).
then(function() {
}).
catch(function() {
});
```
## Important Notes
Normal co is likely faster so using co-promise only where you need to
return a promise instead of a thunk (like to another api which expects a
promise). This is generally okay since co-promise is only needed for the
very top level generator the rest of the "yieldables" will use normal co
functionality and not be wrapped with an extra layer of promises.