incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r448445 - /incubator/xap/trunk/src/xap/util/ArrayHelper.js
Date Thu, 21 Sep 2006 03:13:17 GMT
Author: jmargaris
Date: Wed Sep 20 20:13:17 2006
New Revision: 448445

URL: http://svn.apache.org/viewvc?view=rev&rev=448445
Log:
added insertElementAt() method

Modified:
    incubator/xap/trunk/src/xap/util/ArrayHelper.js

Modified: incubator/xap/trunk/src/xap/util/ArrayHelper.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/util/ArrayHelper.js?view=diff&rev=448445&r1=448444&r2=448445
==============================================================================
--- incubator/xap/trunk/src/xap/util/ArrayHelper.js (original)
+++ incubator/xap/trunk/src/xap/util/ArrayHelper.js Wed Sep 20 20:13:17 2006
@@ -39,6 +39,28 @@
  */
 xap.util.ArrayHelper = function(){}
 
+
+/**
+ * Removes the first occurence of the given element
+ * from the given array.
+ * 
+ * @param {Array} array The array to insert into
+ * @param element The element to add to the array.
+ * @param index The place to add the new element. If left out or less than zero
+ * element will be appended to end.
+ * @return {Array} The array with the element removed.
+ */ 
+xap.util.ArrayHelper.insertElementAt = function( array, element, index){
+	if (!array){
+		return null;
+	}	
+	if (index && index>0){
+		return array.splice(index,0, element);
+	}
+	else{
+		return array.push(element);
+	}
+}
 /**
  * Removes the first occurence of the given element
  * from the given array.



Mime
View raw message