mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 20:07:49 +00:00
Ensure _.chunk floors size values. [closes #1243]
This commit is contained in:
@@ -4527,7 +4527,7 @@
|
|||||||
if (guard ? isIterateeCall(array, size, guard) : size == null) {
|
if (guard ? isIterateeCall(array, size, guard) : size == null) {
|
||||||
size = 1;
|
size = 1;
|
||||||
} else {
|
} else {
|
||||||
size = nativeMax(+size || 1, 1);
|
size = nativeMax(floor(size) || 1, 1);
|
||||||
}
|
}
|
||||||
var index = 0,
|
var index = 0,
|
||||||
length = array ? array.length : 0,
|
length = array ? array.length : 0,
|
||||||
|
|||||||
@@ -1846,6 +1846,10 @@
|
|||||||
deepEqual(actual, expected);
|
deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should floor `size` values', 1, function() {
|
||||||
|
deepEqual(_.chunk(array, array.length / 4), [[0], [1], [2], [3], [4], [5]]);
|
||||||
|
});
|
||||||
|
|
||||||
test('should work as an iteratee for methods like `_.map`', 1, function() {
|
test('should work as an iteratee for methods like `_.map`', 1, function() {
|
||||||
var actual = _.map([[1, 2], [3, 4]], _.chunk);
|
var actual = _.map([[1, 2], [3, 4]], _.chunk);
|
||||||
deepEqual(actual, [[[1], [2]], [[3], [4]]]);
|
deepEqual(actual, [[[1], [2]], [[3], [4]]]);
|
||||||
|
|||||||
Reference in New Issue
Block a user