Remove goog.array.find
This commit is contained in:
@@ -173,3 +173,28 @@ ol.array.remove = function(arr, obj) {
|
||||
}
|
||||
return i > -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array<VALUE>} arr The array to modify.
|
||||
* @param {?function(this:THISVAL, VALUE, number, ?) : boolean} func The function to compare.
|
||||
* @param {THISVAL=} thisArg Optional this argument for the function.
|
||||
* @template VALUE,THISVAL
|
||||
* @return {VALUE} If the element was removed.
|
||||
*/
|
||||
ol.array.find = function(arr, func, 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(thisArg, value, i, list)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
'config "layer" must not be null');
|
||||
|
||||
var layers = wmtsCap['Contents']['Layer'];
|
||||
var l = goog.array.find(layers, function(elt, index, array) {
|
||||
var l = ol.array.find(layers, function(elt, index, array) {
|
||||
return elt['Identifier'] == config['layer'];
|
||||
});
|
||||
goog.asserts.assert(l, 'found a matching layer in Contents/Layer');
|
||||
@@ -340,7 +340,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
if ('projection' in config) {
|
||||
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
||||
function(elt, index, array) {
|
||||
var tileMatrixSet = goog.array.find(tileMatrixSets, function(el) {
|
||||
var tileMatrixSet = ol.array.find(tileMatrixSets, function(el) {
|
||||
return el['Identifier'] == elt['TileMatrixSet'];
|
||||
});
|
||||
return tileMatrixSet['SupportedCRS'].replace(
|
||||
@@ -397,7 +397,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
}
|
||||
|
||||
var matrixSets = wmtsCap['Contents']['TileMatrixSet'];
|
||||
var matrixSetObj = goog.array.find(matrixSets, function(elt, index, array) {
|
||||
var matrixSetObj = ol.array.find(matrixSets, function(elt, index, array) {
|
||||
return elt['Identifier'] == matrixSet;
|
||||
});
|
||||
goog.asserts.assert(matrixSetObj,
|
||||
@@ -457,7 +457,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var gets = wmtsCap['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'];
|
||||
|
||||
for (var i = 0, ii = gets.length; i < ii; ++i) {
|
||||
var constraint = goog.array.find(gets[i]['Constraint'],
|
||||
var constraint = ol.array.find(gets[i]['Constraint'],
|
||||
function(elt, index, array) {
|
||||
return elt['name'] == 'GetEncoding';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user