Created
January 26, 2011 03:37
-
-
Save no6v/796181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/public/javascripts/prototype.js b/public/javascripts/prototype.js | |
index dfe8ab4..bd16ae9 100644 | |
--- a/public/javascripts/prototype.js | |
+++ b/public/javascripts/prototype.js | |
@@ -644,6 +644,20 @@ var Enumerable = { | |
return results; | |
}, | |
+ count: function() { | |
+ var item = arguments[0]; | |
+ switch (typeof item) { | |
+ case 'undefined': return this.length; | |
+ case 'function': return this.select(item).length; | |
+ default: | |
+ var c = 0; | |
+ this.each(function(value, index){ | |
+ if (value == item) c++; | |
+ }); | |
+ return c; | |
+ } | |
+ }, | |
+ | |
detect: function(iterator, context) { | |
var result; | |
this.each(function(value, index) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment