UNPKG

568 BJavaScriptView Raw
1/**
2 * Array utilities
3 */
4
5import {matchCase} from './string';
6
7/**
8 * Checks if given item can be found in the passed collection
9 * @param {Array} arr collection
10 * @param {Any} val item to search
11 * @param {Boolean} caseSensitive respects case if true
12 * @return {Boolean}
13 */
14export const has = (arr, val, caseSensitive) => {
15 let sCase = Boolean(caseSensitive);
16 for (var i = 0, l = arr.length; i < l; i++) {
17 if (matchCase(arr[i].toString(), sCase) === val) {
18 return true;
19 }
20 }
21 return false;
22};