1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import baseIndexOf from './_baseIndexOf.js';
- import isArrayLike from './isArrayLike.js';
- import isString from './isString.js';
- import toInteger from './toInteger.js';
- import values from './values.js';
- var nativeMax = Math.max;
- function includes(collection, value, fromIndex, guard) {
- collection = isArrayLike(collection) ? collection : values(collection);
- fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
- var length = collection.length;
- if (fromIndex < 0) {
- fromIndex = nativeMax(length + fromIndex, 0);
- }
- return isString(collection)
- ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
- : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
- }
- export default includes;
|