Rename _.includes param target to value.

This commit is contained in:
John-David Dalton
2015-11-08 19:42:54 -08:00
parent 1309f37a7e
commit 9c44430975

View File

@@ -7196,7 +7196,7 @@
}); });
/** /**
* Checks if `target` is in `collection` using * Checks if `value` is in `collection` using
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it's used as the offset * for equality comparisons. If `fromIndex` is negative, it's used as the offset
* from the end of `collection`. * from the end of `collection`.
@@ -7205,10 +7205,10 @@
* @memberOf _ * @memberOf _
* @category Collection * @category Collection
* @param {Array|Object|string} collection The collection to search. * @param {Array|Object|string} collection The collection to search.
* @param {*} target The value to search for. * @param {*} value The value to search for.
* @param {number} [fromIndex=0] The index to search from. * @param {number} [fromIndex=0] The index to search from.
* @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`.
* @returns {boolean} Returns `true` if `target` is found, else `false`. * @returns {boolean} Returns `true` if `value` is found, else `false`.
* @example * @example
* *
* _.includes([1, 2, 3], 1); * _.includes([1, 2, 3], 1);
@@ -7223,7 +7223,7 @@
* _.includes('pebbles', 'eb'); * _.includes('pebbles', 'eb');
* // => true * // => true
*/ */
function includes(collection, target, fromIndex, guard) { function includes(collection, value, fromIndex, guard) {
collection = isArrayLike(collection) ? collection : values(collection); collection = isArrayLike(collection) ? collection : values(collection);
fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
@@ -7232,8 +7232,8 @@
fromIndex = nativeMax(length + fromIndex, 0); fromIndex = nativeMax(length + fromIndex, 0);
} }
return isString(collection) return isString(collection)
? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1) ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
: (!!length && baseIndexOf(collection, target, fromIndex) > -1); : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
} }
/** /**