Remove goog.array.findIndex

This commit is contained in:
Nicholas L
2016-01-17 18:37:43 +13:00
parent d820b54443
commit 9b492f49c7
2 changed files with 28 additions and 4 deletions

View File

@@ -239,3 +239,28 @@ ol.array.stableSort = function(arr, compareFnc) {
arr[i] = tmp[i].value;
}
}
/**
* @param {goog.array.ArrayLike} arr The first array to compare..
* @param {Function} func Optional comparison function.
* @param {THISVAL=} opt_thisArg Optional this argument for the function.
* @template THISVAL
* @return {number} Whether the two arrays are equal.
*/
ol.array.findIndex = function(arr, func, opt_thisArg) {
if (typeof func !== 'function') {
throw new TypeError('func must be a function');
}
var list = Object(arr);
var length = list.length >>> 0;
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (func.call(opt_thisArg, value, i, list)) {
return i;
}
}
return -1;
}