Skip to content

Instantly share code, notes, and snippets.

@couto
Created July 28, 2013 18:16
Show Gist options
  • Save couto/6099504 to your computer and use it in GitHub Desktop.
Save couto/6099504 to your computer and use it in GitHub Desktop.
var EventEmitter = require('events').EventEmitter,
callback = (function () {
var called = 0,
spy = function () { called += 1; };
spy.callCount = function () {
return called;
};
return spy;
}());
var emitter = new EventEmitter();
emitter.on('name', callback);
emitter.once('name', callback);
emitter.emit('name');
console.log(callback.callCount());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment