From 0b20d89d62a7d4f8724925c15d30fff9b20d248d Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 15 Apr 2015 19:20:41 -0700 Subject: [PATCH] Ensure `_.times` floors `n` float values. --- lodash.src.js | 2 +- test/test.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index c96d2b290..49e099755 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11651,7 +11651,7 @@ * // => also invokes `mage.castSpell(n)` three times */ function times(n, iteratee, thisArg) { - n = +n; + n = floor(n); // Exit early to avoid a JSC JIT bug in Safari 8 // where `Array(0)` is treated as `Array(1)`. diff --git a/test/test.js b/test/test.js index 624f726b9..35367f035 100644 --- a/test/test.js +++ b/test/test.js @@ -15544,6 +15544,11 @@ }); }); + test('should floor `n` float values', 1, function() { + var actual = _.times(2.4, _.indentify); + deepEqual(actual, [0, 1]); + }); + test('should provide the correct `iteratee` arguments', 1, function() { var args;