00001 var baseIndexOf = require('./_baseIndexOf'),
00002 isArrayLike = require('./isArrayLike'),
00003 isString = require('./isString'),
00004 toInteger = require('./toInteger'),
00005 values = require('./values');
00006
00007
00008 var nativeMax = Math.max;
00009
00040 function includes(collection, value, fromIndex, guard) {
00041 collection = isArrayLike(collection) ? collection : values(collection);
00042 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
00043
00044 var length = collection.length;
00045 if (fromIndex < 0) {
00046 fromIndex = nativeMax(length + fromIndex, 0);
00047 }
00048 return isString(collection)
00049 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
00050 : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
00051 }
00052
00053 module.exports = includes;