https://github.com/zenflow/gather-events
Listen to an EventEmitter for some events and then return an ordered array of events that were emitted.
https://github.com/zenflow/gather-events
Last synced: about 1 year ago
JSON representation
Listen to an EventEmitter for some events and then return an ordered array of events that were emitted.
- Host: GitHub
- URL: https://github.com/zenflow/gather-events
- Owner: zenflow
- License: mit
- Created: 2015-05-18T02:37:00.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-06T03:05:35.000Z (about 11 years ago)
- Last Synced: 2025-03-14T06:18:12.445Z (over 1 year ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gather-events
Listen to an EventEmitter for some events and then return an ordered array of events that were emitted.
[](https://travis-ci.org/zenflow/gather-events?branch=master)
[](https://david-dm.org/zenflow/gather-events)
[](https://david-dm.org/zenflow/gather-events#info=devDependencies)
[](https://www.npmjs.com/package/gather-events)
### example usage
```js
var EventEmitter = require('events').EventEmitter;
var gatherEvents = require('./lib');
var event_emitter = new EventEmitter;
var endGather = gatherEvents(event_emitter, ['foo', 'bar']);
event_emitter.emit('foo', {a: 1}, 2);
event_emitter.emit('bar', 3);
var gathered = endGather();
console.log(JSON.stringify(gathered));
// -> [{"name":"foo","args":[{"a":1},2]},{"name":"bar","args":[3]}]
// --- or /w shorthand option---
var gathered = endGather(true);
console.log(JSON.stringify(gathered));
// -> [{"foo":[{"a":1},2],{"bar": [3]}]
```
### changelog
#### v1.1.0
- added shorthand option
- enhanced tests
#### v1.0.2
- enhanced readme
- enhanced package.json