Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/segment-boneyard/co-event

Consume events from an event emitter in generators
https://github.com/segment-boneyard/co-event

Last synced: about 5 hours ago
JSON representation

Consume events from an event emitter in generators

Awesome Lists containing this project

README

        

# co-event

Return any event that an emitter emits.

## Installation

```
$ npm install co-event
```

## Example

Returns events in sequence, with the `.type` and `.args` keys. The original events are still emitted except for "error", as node will think no handler is registered.

```js
var event = require('co-event');

var e;
while (e = yield event(emitter)) {
switch (e.type) {
case 'end':
break;

case 'close':
break;

case 'error':
break;
}
}
```

# License

MIT