mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Remove fromIndex type check from _.includes.
This commit is contained in:
@@ -6117,7 +6117,7 @@
|
||||
function includes(collection, target, fromIndex, guard) {
|
||||
collection = isArrayLike(collection) ? collection : values(collection);
|
||||
var length = collection.length;
|
||||
if (guard || typeof fromIndex != 'number') {
|
||||
if (guard || !fromIndex) {
|
||||
fromIndex = 0;
|
||||
} else {
|
||||
fromIndex = toInteger(fromIndex);
|
||||
|
||||
10
test/test.js
10
test/test.js
@@ -5572,8 +5572,10 @@
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should work with ' + key + ' and treat non-number `fromIndex` values as `0`', 1, function() {
|
||||
strictEqual(_.includes(collection, values[0], '1'), true);
|
||||
test('should work with ' + key + ' and coerce non-integer `fromIndex` values to integers', 3, function() {
|
||||
strictEqual(_.includes(collection, values[0], '1'), false);
|
||||
strictEqual(_.includes(collection, values[0], 0.1), true);
|
||||
strictEqual(_.includes(collection, values[0], NaN), true);
|
||||
});
|
||||
|
||||
test('should work with ' + key + ' and a negative `fromIndex`', 2, function() {
|
||||
@@ -5633,10 +5635,6 @@
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should not be possible to perform a binary search', 1, function() {
|
||||
strictEqual(_.includes([3, 2, 1], 3, true), true);
|
||||
});
|
||||
|
||||
test('should match `NaN`', 1, function() {
|
||||
strictEqual(_.includes([1, NaN, 3], NaN), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user