Remove goog.array.isSorted

This commit is contained in:
Nicholas L
2016-01-17 18:52:51 +13:00
parent 9b492f49c7
commit ab793a58b6
3 changed files with 15 additions and 4 deletions

View File

@@ -264,3 +264,16 @@ ol.array.findIndex = function(arr, func, opt_thisArg) {
} }
return -1; return -1;
} }
ol.array.isSorted = function(arr, opt_func, opt_strict) {
var compare = opt_func || function(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
};
return arr.every(function(currentVal, index) {
if (index === 0) {
return true;
}
var res = compare(arr[index - 1], currentVal);
return !(res > 0 || opt_strict && res === 0);
});
}

View File

@@ -1,7 +1,6 @@
goog.provide('ol.source.Image'); goog.provide('ol.source.Image');
goog.provide('ol.source.ImageEvent'); goog.provide('ol.source.ImageEvent');
goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.events.Event'); goog.require('goog.events.Event');
goog.require('ol.Attribution'); goog.require('ol.Attribution');
@@ -52,7 +51,7 @@ ol.source.Image = function(options) {
this.resolutions_ = options.resolutions !== undefined ? this.resolutions_ = options.resolutions !== undefined ?
options.resolutions : null; options.resolutions : null;
goog.asserts.assert(!this.resolutions_ || goog.asserts.assert(!this.resolutions_ ||
goog.array.isSorted(this.resolutions_, ol.array.isSorted(this.resolutions_,
function(a, b) { function(a, b) {
return b - a; return b - a;
}, true), 'resolutions must be null or sorted in descending order'); }, true), 'resolutions must be null or sorted in descending order');

View File

@@ -1,6 +1,5 @@
goog.provide('ol.tilegrid.TileGrid'); goog.provide('ol.tilegrid.TileGrid');
goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol'); goog.require('ol');
@@ -42,7 +41,7 @@ ol.tilegrid.TileGrid = function(options) {
* @type {!Array.<number>} * @type {!Array.<number>}
*/ */
this.resolutions_ = options.resolutions; this.resolutions_ = options.resolutions;
goog.asserts.assert(goog.array.isSorted(this.resolutions_, function(a, b) { goog.asserts.assert(ol.array.isSorted(this.resolutions_, function(a, b) {
return b - a; return b - a;
}, true), 'resolutions must be sorted in descending order'); }, true), 'resolutions must be sorted in descending order');