https://github.com/connesc/co-wrap-all
Call co.wrap for multiple generator functions
https://github.com/connesc/co-wrap-all
co javascript wrap-all
Last synced: 4 months ago
JSON representation
Call co.wrap for multiple generator functions
- Host: GitHub
- URL: https://github.com/connesc/co-wrap-all
- Owner: connesc
- License: mit
- Created: 2016-09-13T15:35:46.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-07T17:53:40.000Z (over 6 years ago)
- Last Synced: 2025-10-01T13:44:44.821Z (9 months ago)
- Topics: co, javascript, wrap-all
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# co-wrap-all
> Call co.wrap for multiple generator functions
This tiny helper allows to easily call `co.wrap` for multiple generator functions.
For example:
```javascript
// Before
module.exports = {
foo: co.wrap(foo),
bar: co.wrap(bar)
};
// After
module.exports = wrapAll({foo, bar});
```
Also, it is very convenient for defining asynchronous methods:
```javascript
// Common
class Foo {
* bar(arg) { /* ... */ }
* baz(arg) { /* ... */ }
}
// Before
Foo.prototype.bar = co.wrap(Foo.prototype.bar);
Foo.prototype.baz = co.wrap(Foo.prototype.baz);
// After
wrapAll(Foo.prototype);
```
## License
[MIT](https://github.com/connesc/co-wrap-all/blob/master/LICENSE)