From edf37f3e0cd1ff79c052c9fe7706f446c2304cea Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 4 Oct 2014 16:11:36 -0400 Subject: [PATCH] wow, logic fail if you called the same event twice, it will reduce count anyways (so I could have event.any(a,b,c) and call a three times and it would complete. --- src/emitter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/emitter.js b/src/emitter.js index e95b01c216..f0fd9d70c4 100644 --- a/src/emitter.js +++ b/src/emitter.js @@ -6,7 +6,9 @@ var eventEmitter = new (require('events')).EventEmitter(); eventEmitter.all = function(events, callback) { function onEvent(event) { eventEmitter.on(events[event], function() { - events.splice(events.indexOf(event), 1); + if (events.indexOf(event) !== -1) { + events.splice(events.indexOf(event), 1); + } if (events.length === 0) { callback();