mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-10 09:52:33 +02:00
23 lines
545 B
JavaScript
23 lines
545 B
JavaScript
/**
|
|
* Array utilities
|
|
*/
|
|
|
|
import {matchCase} from './string';
|
|
|
|
/**
|
|
* Checks if given item can be found in the passed collection
|
|
* @param {Array} arr collection
|
|
* @param {Any} val item to search
|
|
* @param {Boolean} caseSensitive respects case if true
|
|
* @return {Boolean}
|
|
*/
|
|
export const has = (arr, val, caseSensitive) => {
|
|
let sCase = Boolean(caseSensitive);
|
|
for (var i = 0, l = arr.length; i < l; i++) {
|
|
if (matchCase(arr[i].toString(), sCase) === val) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|