From 418906faffc9c71e125a41383a39b88303ea3c20 Mon Sep 17 00:00:00 2001 From: Joe MacMahon Date: Wed, 20 Jun 2012 00:52:49 +0100 Subject: [PATCH] Fixed conflicting .each() function by renaming to .withAll(). --- modules/poll.js | 6 +++--- snippets.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/poll.js b/modules/poll.js index e8deed1..a6f3911 100644 --- a/modules/poll.js +++ b/modules/poll.js @@ -172,7 +172,7 @@ var poll = function(dbot) { }); // Count votes - polls[name].votes.each(function (name, vote) { + polls[name].votes.withAll(function (name, vote) { voted = false; vote.each(function (pref) { if(!voted && rounds[roundn].hasOwnProperty(pref)) { @@ -184,7 +184,7 @@ var poll = function(dbot) { // Find the loser var min = polls[name].votes.length() + 1; - rounds[roundn].each(function (option, count) { + rounds[roundn].withAll(function (option, count) { if(count < min) { roundLoser = option; min = count; @@ -197,7 +197,7 @@ var poll = function(dbot) { order = eliminated.reverse().join(', ') } else { var votesArr = []; - polls[name].votes.each(function(option, count) { + polls[name].votes.withAll(function(option, count) { votesArr.push([option, count]); }); diff --git a/snippets.js b/snippets.js index 13d1f00..cfcfae3 100644 --- a/snippets.js +++ b/snippets.js @@ -164,7 +164,7 @@ Object.prototype.isArray = function(obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }; -Object.prototype.each = function(fun) { +Object.prototype.withAll = function(fun) { for(key in this) if(this.hasOwnProperty(key)) fun(key, this[key]);