r9587 - helma-ng/trunk/modules/core

[email protected]
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090408131301.B0DB63D0D6@mia>
Author: hannes
Date: 2009-04-08 15:13:01 +0200 (Wed, 08 Apr 2009)
New Revision: 9587

Modified:
   helma-ng/trunk/modules/core/array.js
Log:
Merge git://github.com/leobm/helma-ng into merger

* git://github.com/leobm/helma-ng:
  added array helpers.

Details at http://dev.helma.org/trac/helma/changeset/9587

Modified: helma-ng/trunk/modules/core/array.js
===================================================================
--- helma-ng/trunk/modules/core/array.js	2009-04-08 11:24:35 UTC (rev 9586)
+++ helma-ng/trunk/modules/core/array.js	2009-04-08 13:13:01 UTC (rev 9587)
@@ -84,3 +84,30 @@
         return result;
     }
 });
+
+Object.defineProperty(Array.prototype, "max", {
+		value: function() {
+			return Math.max.apply( Math, this );
+		}
+});
+
+Object.defineProperty(Array.prototype, "min", {
+		value: function() {
+			return Math.min.apply( Math, this );
+		}
+});
+
+Object.defineProperty(Array.prototype, "partition", {
+		value: function(fn) {
+			var trues = [], falses = [];
+			for (var i=0; i<this.length; i++) {
+				if (fn(this[i], i)) {
+					trues.push(this[i]);
+				} else {
+					falses.push(this[i]);
+				}
+			}
+			return [trues, falses]
+		}
+});
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.