Replace indexOf with includes, startsWith

This replaces almost every instance of indexOf on both String and
Array.  There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.

Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
This commit is contained in:
Joey Parrish
2018-09-13 15:59:40 -07:00
parent 19c9625edc
commit 7091275cbf
39 changed files with 107 additions and 159 deletions
-14
View File
@@ -42,20 +42,6 @@ describe('ArrayUtils', function() {
});
});
describe('indexOf', function() {
it('will find a matching element', function() {
let arr = ['aaa', 'bbb', 'ccc'];
let comparator = function(a, b) { return a[0] === b[0]; };
expect(ArrayUtils.indexOf(arr, 'bat', comparator)).toBe(1);
});
it('will return -1 if not found', function() {
let arr = ['aaa', 'bbb', 'ccc'];
let comparator = function(a, b) { return a[0] === b[0]; };
expect(ArrayUtils.indexOf(arr, 'zoo', comparator)).toBe(-1);
});
});
describe('hasSameElements', function() {
it('determines same elements', () => {
expectEqual([], []);