diff --git a/lib/events.js b/lib/events.js index 2d2d5d19cbe..9b13c80f8ed 100644 --- a/lib/events.js +++ b/lib/events.js @@ -137,6 +137,10 @@ EventEmitter.prototype.addListener = function(type, listener) { EventEmitter.prototype.on = EventEmitter.prototype.addListener; EventEmitter.prototype.once = function(type, listener) { + if ('function' !== typeof listener) { + throw new Error('.once only takes instances of Function'); + } + var self = this; self.on(type, function g() { self.removeListener(type, g);