r10014 - apps/modules/trunk/core

[email protected] Mon, 22 Feb 2010 16:14:24 +0100 (CET)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20100222151424.AB7533D0E2@mia>
Author: hannes
Date: 2010-02-22 16:14:24 +0100 (Mon, 22 Feb 2010)
New Revision: 10014

Modified:
   apps/modules/trunk/core/Array.js
Log:
Remove indexOf and lastIndexOf from Array.prototype as they're part of JS 1.5. Simplify Array.prototype.contains.

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

Modified: apps/modules/trunk/core/Array.js
===================================================================
--- apps/modules/trunk/core/Array.js	2010-02-05 17:29:06 UTC (rev 10013)
+++ apps/modules/trunk/core/Array.js	2010-02-22 15:14:24 UTC (rev 10014)
@@ -23,48 +23,14 @@
  * @addon
  */
 
-/**
- * Return the first index position of a value
- * contained in an array, or -1 if it isn't contained.
- * @param {Object} val the value to check
- * @return {int} the index of the first occurence of val, or -1
- */
-Array.prototype.indexOf = function(val) {
-   var i = -1;
-   while (i++ < this.length -1) {
-      if (this[i] == val)
-         return i;
-   }
-   return -1;
-};
 
-
 /**
- * return the last index position of a value 
- * contained in an array, or -1 if it isn't contained.
+ * Check if this array contains a specific value.
  * @param {Object} val the value to check
- * @return {int} the index of the first occurence of val, or -1
- */
-Array.prototype.lastIndexOf = function(val) {
-   var i = 1;
-   while (this.length - i++ >= 0) {
-      if (this[i] == val)
-         return i;
-   }
-   return -1;
-};
-
-
-/**
- * check if an array passed as argument contains
- * a specific value (start from end of array)
- * @param {Object} val the value to check
  * @return {boolean} true if the value is contained
  */
 Array.prototype.contains = function(val) {
-   if (this.indexOf(val) > -1)
-      return true;
-   return false;
+   return this.indexOf(val) > -1;
 };
 
 /**