]> git.wh0rd.org - tt-rss.git/blobdiff - lib/dojo/_base/array.js
lib: Upgrade Dojo and Dijit from 1.8.3 to 1.12.1
[tt-rss.git] / lib / dojo / _base / array.js
index 26fa1900d320855686a6de7523e36081f3b2c925..abbdec2e98375f93b07563ac403f45f1614ee728 100644 (file)
@@ -1,262 +1,8 @@
 /*
-       Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
+       Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
        Available via Academic Free License >= 2.1 OR the modified BSD license.
        see: http://dojotoolkit.org/license for details
 */
 
-
-if(!dojo._hasResource["dojo._base.array"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojo._base.array"] = true;
-dojo.require("dojo._base.lang");
-dojo.provide("dojo._base.array");
-
-(function(){
-       var _getParts = function(arr, obj, cb){
-               return [ 
-                       (typeof arr == "string") ? arr.split("") : arr, 
-                       obj || dojo.global,
-                       // FIXME: cache the anonymous functions we create here?
-                       (typeof cb == "string") ? new Function("item", "index", "array", cb) : cb
-               ];
-       };
-
-       var everyOrSome = function(/*Boolean*/every, /*Array|String*/arr, /*Function|String*/callback, /*Object?*/thisObject){
-               var _p = _getParts(arr, thisObject, callback); arr = _p[0];
-               for(var i=0,l=arr.length; i<l; ++i){
-                       var result = !!_p[2].call(_p[1], arr[i], i, arr);
-                       if(every ^ result){
-                               return result; // Boolean
-                       }
-               }
-               return every; // Boolean
-       };
-
-       dojo.mixin(dojo, {
-               indexOf: function(      /*Array*/               array, 
-                                                       /*Object*/              value,
-                                                       /*Integer?*/    fromIndex,
-                                                       /*Boolean?*/    findLast){
-                       // summary:
-                       //              locates the first index of the provided value in the
-                       //              passed array. If the value is not found, -1 is returned.
-                       // description:
-                       //              This method corresponds to the JavaScript 1.6 Array.indexOf method, with one difference: when
-                       //              run over sparse arrays, the Dojo function invokes the callback for every index whereas JavaScript 
-                       //              1.6's indexOf skips the holes in the sparse array.
-                       //              For details on this method, see:
-                       //                      https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/indexOf
-
-                       var step = 1, end = array.length || 0, i = 0;
-                       if(findLast){
-                               i = end - 1;
-                               step = end = -1;
-                       }
-                       if(fromIndex != undefined){ i = fromIndex; }
-                       if((findLast && i > end) || i < end){
-                               for(; i != end; i += step){
-                                       if(array[i] == value){ return i; }
-                               }
-                       }
-                       return -1;      // Number
-               },
-
-               lastIndexOf: function(/*Array*/array, /*Object*/value, /*Integer?*/fromIndex){
-                       // summary:
-                       //              locates the last index of the provided value in the passed
-                       //              array. If the value is not found, -1 is returned.
-                       // description:
-                       //              This method corresponds to the JavaScript 1.6 Array.lastIndexOf method, with one difference: when
-                       //              run over sparse arrays, the Dojo function invokes the callback for every index whereas JavaScript 
-                       //              1.6's lastIndexOf skips the holes in the sparse array.
-                       //              For details on this method, see:
-                       //                      https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/lastIndexOf
-                       return dojo.indexOf(array, value, fromIndex, true); // Number
-               },
-
-               forEach: function(/*Array|String*/arr, /*Function|String*/callback, /*Object?*/thisObject){
-                       //      summary:
-                       //              for every item in arr, callback is invoked. Return values are ignored.
-                       //              If you want to break out of the loop, consider using dojo.every() or dojo.some().
-                       //              forEach does not allow breaking out of the loop over the items in arr.
-                       //      arr:
-                       //              the array to iterate over. If a string, operates on individual characters.
-                       //      callback:
-                       //              a function is invoked with three arguments: item, index, and array
-                       //      thisObject:
-                       //              may be used to scope the call to callback
-                       //      description:
-                       //              This function corresponds to the JavaScript 1.6 Array.forEach() method, with one difference: when 
-                       //              run over sparse arrays, this implemenation passes the "holes" in the sparse array to
-                       //              the callback function with a value of undefined. JavaScript 1.6's forEach skips the holes in the sparse array.
-                       //              For more details, see:
-                       //                      https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/forEach
-                       //      example:
-                       //      |       // log out all members of the array:
-                       //      |       dojo.forEach(
-                       //      |               [ "thinger", "blah", "howdy", 10 ],
-                       //      |               function(item){
-                       //      |                       console.log(item);
-                       //      |               }
-                       //      |       );
-                       //      example:
-                       //      |       // log out the members and their indexes
-                       //      |       dojo.forEach(
-                       //      |               [ "thinger", "blah", "howdy", 10 ],
-                       //      |               function(item, idx, arr){
-                       //      |                       console.log(item, "at index:", idx);
-                       //      |               }
-                       //      |       );
-                       //      example:
-                       //      |       // use a scoped object member as the callback
-                       //      |       
-                       //      |       var obj = {
-                       //      |               prefix: "logged via obj.callback:", 
-                       //      |               callback: function(item){
-                       //      |                       console.log(this.prefix, item);
-                       //      |               }
-                       //      |       };
-                       //      |       
-                       //      |       // specifying the scope function executes the callback in that scope
-                       //      |       dojo.forEach(
-                       //      |               [ "thinger", "blah", "howdy", 10 ],
-                       //      |               obj.callback,
-                       //      |               obj
-                       //      |       );
-                       //      |       
-                       //      |       // alternately, we can accomplish the same thing with dojo.hitch()
-                       //      |       dojo.forEach(
-                       //      |               [ "thinger", "blah", "howdy", 10 ],
-                       //      |               dojo.hitch(obj, "callback")
-                       //      |       );
-
-                       // match the behavior of the built-in forEach WRT empty arrs
-                       if(!arr || !arr.length){ return; }
-
-                       // FIXME: there are several ways of handilng thisObject. Is
-                       // dojo.global always the default context?
-                       var _p = _getParts(arr, thisObject, callback); arr = _p[0];
-                       for(var i=0,l=arr.length; i<l; ++i){ 
-                               _p[2].call(_p[1], arr[i], i, arr);
-                       }
-               },
-
-               every: function(/*Array|String*/arr, /*Function|String*/callback, /*Object?*/thisObject){
-                       // summary:
-                       //              Determines whether or not every item in arr satisfies the
-                       //              condition implemented by callback.
-                       // arr:
-                       //              the array to iterate on. If a string, operates on individual characters.
-                       // callback:
-                       //              a function is invoked with three arguments: item, index,
-                       //              and array and returns true if the condition is met.
-                       // thisObject:
-                       //              may be used to scope the call to callback
-                       // description:
-                       //              This function corresponds to the JavaScript 1.6 Array.every() method, with one difference: when 
-                       //              run over sparse arrays, this implemenation passes the "holes" in the sparse array to
-                       //              the callback function with a value of undefined. JavaScript 1.6's every skips the holes in the sparse array.
-                       //              For more details, see:
-                       //                      https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/every
-                       // example:
-                       //      |       // returns false
-                       //      |       dojo.every([1, 2, 3, 4], function(item){ return item>1; });
-                       // example:
-                       //      |       // returns true 
-                       //      |       dojo.every([1, 2, 3, 4], function(item){ return item>0; });
-                       return everyOrSome(true, arr, callback, thisObject); // Boolean
-               },
-
-               some: function(/*Array|String*/arr, /*Function|String*/callback, /*Object?*/thisObject){
-                       // summary:
-                       //              Determines whether or not any item in arr satisfies the
-                       //              condition implemented by callback.
-                       // arr:
-                       //              the array to iterate over. If a string, operates on individual characters.
-                       // callback:
-                       //              a function is invoked with three arguments: item, index,
-                       //              and array and returns true if the condition is met.
-                       // thisObject:
-                       //              may be used to scope the call to callback
-                       // description:
-                       //              This function corresponds to the JavaScript 1.6 Array.some() method, with one difference: when 
-                       //              run over sparse arrays, this implemenation passes the "holes" in the sparse array to
-                       //              the callback function with a value of undefined. JavaScript 1.6's some skips the holes in the sparse array.
-                       //              For more details, see:
-                       //                      https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/some
-                       // example:
-                       //      |       // is true
-                       //      |       dojo.some([1, 2, 3, 4], function(item){ return item>1; });
-                       // example:
-                       //      |       // is false
-                       //      |       dojo.some([1, 2, 3, 4], function(item){ return item<1; });
-                       return everyOrSome(false, arr, callback, thisObject); // Boolean
-               },
-
-               map: function(/*Array|String*/arr, /*Function|String*/callback, /*Function?*/thisObject){
-                       // summary:
-                       //              applies callback to each element of arr and returns
-                       //              an Array with the results
-                       // arr:
-                       //              the array to iterate on. If a string, operates on
-                       //              individual characters.
-                       // callback:
-                       //              a function is invoked with three arguments, (item, index,
-                       //              array),  and returns a value
-                       // thisObject:
-                       //              may be used to scope the call to callback
-                       // description:
-                       //              This function corresponds to the JavaScript 1.6 Array.map() method, with one difference: when 
-                       //              run over sparse arrays, this implemenation passes the "holes" in the sparse array to
-                       //              the callback function with a value of undefined. JavaScript 1.6's map skips the holes in the sparse array.
-                       //              For more details, see:
-                       //                      https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
-                       // example:
-                       //      |       // returns [2, 3, 4, 5]
-                       //      |       dojo.map([1, 2, 3, 4], function(item){ return item+1 });
-
-                       var _p = _getParts(arr, thisObject, callback); arr = _p[0];
-                       var outArr = (arguments[3] ? (new arguments[3]()) : []);
-                       for(var i=0,l=arr.length; i<l; ++i){
-                               outArr.push(_p[2].call(_p[1], arr[i], i, arr));
-                       }
-                       return outArr; // Array
-               },
-
-               filter: function(/*Array*/arr, /*Function|String*/callback, /*Object?*/thisObject){
-                       // summary:
-                       //              Returns a new Array with those items from arr that match the
-                       //              condition implemented by callback.
-                       // arr:
-                       //              the array to iterate over.
-                       // callback:
-                       //              a function that is invoked with three arguments (item,
-                       //              index, array). The return of this function is expected to
-                       //              be a boolean which determines whether the passed-in item
-                       //              will be included in the returned array.
-                       // thisObject:
-                       //              may be used to scope the call to callback
-                       // description:
-                       //              This function corresponds to the JavaScript 1.6 Array.filter() method, with one difference: when 
-                       //              run over sparse arrays, this implemenation passes the "holes" in the sparse array to
-                       //              the callback function with a value of undefined. JavaScript 1.6's filter skips the holes in the sparse array. 
-                       //              For more details, see:
-                       //                      https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
-                       // example:
-                       //      |       // returns [2, 3, 4]
-                       //      |       dojo.filter([1, 2, 3, 4], function(item){ return item>1; });
-
-                       var _p = _getParts(arr, thisObject, callback); arr = _p[0];
-                       var outArr = [];
-                       for(var i=0,l=arr.length; i<l; ++i){
-                               if(_p[2].call(_p[1], arr[i], i, arr)){
-                                       outArr.push(arr[i]);
-                               }
-                       }
-                       return outArr; // Array
-               }
-       });
-})();
-/*
-*/
-
-}
+//>>built
+define("dojo/_base/array",["./kernel","../has","./lang"],function(_1,_2,_3){var _4={},u;function _5(fn){return _4[fn]=new Function("item","index","array",fn);};function _6(_7){var _8=!_7;return function(a,fn,o){var i=0,l=a&&a.length||0,_9;if(l&&typeof a=="string"){a=a.split("");}if(typeof fn=="string"){fn=_4[fn]||_5(fn);}if(o){for(;i<l;++i){_9=!fn.call(o,a[i],i,a);if(_7^_9){return !_9;}}}else{for(;i<l;++i){_9=!fn(a[i],i,a);if(_7^_9){return !_9;}}}return _8;};};function _a(up){var _b=1,_c=0,_d=0;if(!up){_b=_c=_d=-1;}return function(a,x,_e,_f){if(_f&&_b>0){return _10.lastIndexOf(a,x,_e);}var l=a&&a.length||0,end=up?l+_d:_c,i;if(_e===u){i=up?_c:l+_d;}else{if(_e<0){i=l+_e;if(i<0){i=_c;}}else{i=_e>=l?l+_d:_e;}}if(l&&typeof a=="string"){a=a.split("");}for(;i!=end;i+=_b){if(a[i]==x){return i;}}return -1;};};var _10={every:_6(false),some:_6(true),indexOf:_a(true),lastIndexOf:_a(false),forEach:function(arr,_11,_12){var i=0,l=arr&&arr.length||0;if(l&&typeof arr=="string"){arr=arr.split("");}if(typeof _11=="string"){_11=_4[_11]||_5(_11);}if(_12){for(;i<l;++i){_11.call(_12,arr[i],i,arr);}}else{for(;i<l;++i){_11(arr[i],i,arr);}}},map:function(arr,_13,_14,Ctr){var i=0,l=arr&&arr.length||0,out=new (Ctr||Array)(l);if(l&&typeof arr=="string"){arr=arr.split("");}if(typeof _13=="string"){_13=_4[_13]||_5(_13);}if(_14){for(;i<l;++i){out[i]=_13.call(_14,arr[i],i,arr);}}else{for(;i<l;++i){out[i]=_13(arr[i],i,arr);}}return out;},filter:function(arr,_15,_16){var i=0,l=arr&&arr.length||0,out=[],_17;if(l&&typeof arr=="string"){arr=arr.split("");}if(typeof _15=="string"){_15=_4[_15]||_5(_15);}if(_16){for(;i<l;++i){_17=arr[i];if(_15.call(_16,_17,i,arr)){out.push(_17);}}}else{for(;i<l;++i){_17=arr[i];if(_15(_17,i,arr)){out.push(_17);}}}return out;},clearCache:function(){_4={};}};1&&_3.mixin(_1,_10);return _10;});
\ No newline at end of file