mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Should coerce float start and end params of _.slice to integers.
This commit is contained in:
@@ -2661,7 +2661,8 @@
|
|||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end += length;
|
end += length;
|
||||||
}
|
}
|
||||||
length = start > end ? 0 : (end - start);
|
length = start > end ? 0 : (end - start) >>> 0;
|
||||||
|
start >>>= 0;
|
||||||
|
|
||||||
var result = Array(length);
|
var result = Array(length);
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
|
|||||||
@@ -11690,8 +11690,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should coerce `start` and `end` to finite numbers', 1, function() {
|
test('should coerce `start` and `end` to finite numbers', 1, function() {
|
||||||
var actual = [_.slice(array, '0', 1), _.slice(array, 0, '1'), _.slice(array, '1'), _.slice(array, NaN, 1), _.slice(array, 1, NaN)];
|
var actual = [_.slice(array, 0.1, 1.1), _.slice(array, '0', 1), _.slice(array, 0, '1'), _.slice(array, '1'), _.slice(array, NaN, 1), _.slice(array, 1, NaN)];
|
||||||
deepEqual(actual, [[1], [1], [2, 3], [1], []]);
|
deepEqual(actual, [[1], [1], [1], [2, 3], [1], []]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work as an iteratee for `_.map`', 2, function() {
|
test('should work as an iteratee for `_.map`', 2, function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user