1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- var baseIndexOf = require('./_baseIndexOf'),
- isArrayLike = require('./isArrayLike'),
- isString = require('./isString'),
- toInteger = require('./toInteger'),
- values = require('./values');
-
-
- 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);
- }
-
- module.exports = includes;
|