You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2006/09/21 03:13:17 UTC
svn commit: r448445 - /incubator/xap/trunk/src/xap/util/ArrayHelper.js
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.