Browse Source

EventEmitter#once only takes instanceof function

v0.7.4-release
Aaron Heckmann 14 years ago
committed by Ryan Dahl
parent
commit
a4dad95be3
  1. 4
      lib/events.js

4
lib/events.js

@ -137,6 +137,10 @@ EventEmitter.prototype.addListener = function(type, listener) {
EventEmitter.prototype.on = EventEmitter.prototype.addListener; EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.once = function(type, listener) { EventEmitter.prototype.once = function(type, listener) {
if ('function' !== typeof listener) {
throw new Error('.once only takes instances of Function');
}
var self = this; var self = this;
self.on(type, function g() { self.on(type, function g() {
self.removeListener(type, g); self.removeListener(type, g);

Loading…
Cancel
Save