mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Merge pull request #327 from stereokai/master
Enable _.range() to accept a 0 for step. Former-commit-id: 6a778327f216de6c606ba091312db9f1b8f85c4e
This commit is contained in:
@@ -4687,7 +4687,7 @@
|
|||||||
*/
|
*/
|
||||||
function range(start, end, step) {
|
function range(start, end, step) {
|
||||||
start = +start || 0;
|
start = +start || 0;
|
||||||
step = +step || 1;
|
step = isNumber(step) ? step : 1;
|
||||||
|
|
||||||
if (end == null) {
|
if (end == null) {
|
||||||
end = start;
|
end = start;
|
||||||
@@ -4696,7 +4696,7 @@
|
|||||||
// use `Array(length)` so engines, like Chakra and V8, avoid slower modes
|
// use `Array(length)` so engines, like Chakra and V8, avoid slower modes
|
||||||
// http://youtu.be/XAqIpGU8ZZk#t=17m25s
|
// http://youtu.be/XAqIpGU8ZZk#t=17m25s
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = nativeMax(0, ceil((end - start) / step)),
|
length = nativeMax(0, ceil((end - start) / (step || 1))),
|
||||||
result = Array(length);
|
result = Array(length);
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user