merge changes for seperator change
[roojs1] / Array.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11  /**
12  * @class Array
13  */
14 Roo.applyIf(Array.prototype, {
15     /**
16      * 
17      * Checks whether or not the specified object exists in the array.
18      * @param {Object} o The object to check for
19      * @return {Number} The index of o in the array (or -1 if it is not found)
20      */
21     indexOf : function(o){
22        for (var i = 0, len = this.length; i < len; i++){
23               if(this[i] == o) { return i; }
24        }
25            return -1;
26     },
27
28     /**
29      * Removes the specified object from the array.  If the object is not found nothing happens.
30      * @param {Object} o The object to remove
31      */
32     remove : function(o){
33        var index = this.indexOf(o);
34        if(index != -1){
35            this.splice(index, 1);
36        }
37     },
38     /**
39      * Map (JS 1.6 compatibility)
40      * @param {Function} function  to call
41      */
42     map : function(fun )
43     {
44         var len = this.length >>> 0;
45         if (typeof fun != "function") {
46             throw new TypeError();
47         }
48         var res = new Array(len);
49         var thisp = arguments[1];
50         for (var i = 0; i < len; i++)
51         {
52             if (i in this) {
53                 res[i] = fun.call(thisp, this[i], i, this);
54             }
55         }
56
57         return res;
58     }
59     
60 });
61
62
63