gather-events

1.1.0 • Public • Published

gather-events

Listen to an EventEmitter for some events and then return an ordered array of events that were emitted.

build status dependencies dev-dependencies

npm

example usage

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

Package Sidebar

Install

npm i gather-events

Weekly Downloads

5

Version

1.1.0

License

MIT

Last publish

Collaborators

  • zen_flow