From 02a132a9d78212a6c58d74ef350890ab027e0019 Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 28 May 2015 14:29:26 -0400 Subject: [PATCH] Ensure `_.chunk` floors `size` values. [closes #1243] --- lodash.src.js | 2 +- test/test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index d8520b05b..f8832a5bd 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -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, diff --git a/test/test.js b/test/test.js index 0076944ba..9ac8952d3 100644 --- a/test/test.js +++ b/test/test.js @@ -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]]]);