From a4dad95be3e0051da7109aa016e9023ba714769b Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Tue, 15 Mar 2011 09:01:24 -0400 Subject: [PATCH] EventEmitter#once only takes instanceof function --- lib/events.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/events.js b/lib/events.js index 2d2d5d19cb..9b13c80f8e 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);