Use Array.prototype.findIndex
This commit is contained in:
@@ -3,7 +3,6 @@ import {
|
||||
binarySearch,
|
||||
equals,
|
||||
extend,
|
||||
findIndex,
|
||||
isSorted,
|
||||
linearFindNearest,
|
||||
numberSafeCompareFunction,
|
||||
@@ -382,26 +381,6 @@ describe('ol/array.js', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('findIndex', function () {
|
||||
it('finds index of numbers in an array', function () {
|
||||
const a = [0, 1, 2, 3];
|
||||
const b = findIndex(a, function (val, index, a2) {
|
||||
expect(a).to.equal(a2);
|
||||
expect(typeof index).to.be('number');
|
||||
return val > 1;
|
||||
});
|
||||
expect(b).to.be(2);
|
||||
});
|
||||
|
||||
it('returns -1 when an item in an array is not found', function () {
|
||||
const a = [0, 1, 2, 3];
|
||||
const b = findIndex(a, function (val, index, a2) {
|
||||
return val > 100;
|
||||
});
|
||||
expect(b).to.be(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSorted', function () {
|
||||
it('works with just an array as argument', function () {
|
||||
expect(isSorted([1, 2, 3])).to.be(true);
|
||||
|
||||
Reference in New Issue
Block a user