Ensure _.chunk floors size values. [closes #1243]

This commit is contained in:
jdalton
2015-05-28 14:29:26 -04:00
parent 7c95c5e80a
commit 02a132a9d7
2 changed files with 5 additions and 1 deletions

View File

@@ -4527,7 +4527,7 @@
if (guard ? isIterateeCall(array, size, guard) : size == null) {
size = 1;
} else {
size = nativeMax(+size || 1, 1);
size = nativeMax(floor(size) || 1, 1);
}
var index = 0,
length = array ? array.length : 0,

View File

@@ -1846,6 +1846,10 @@
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() {
var actual = _.map([[1, 2], [3, 4]], _.chunk);
deepEqual(actual, [[[1], [2]], [[3], [4]]]);