* Creates an array of numbers (positive and/or negative) progressing from * `start` up to, but not including, `end`. If `end` is not specified it is * set to `start` with `start` then set to `0`. If `end` is less than `start` * a zero-length range is created unless a negative `step` i
(start, end, step)
| 12864 | * // => [] |
| 12865 | */ |
| 12866 | function range(start, end, step) { |
| 12867 | if (step && isIterateeCall(start, end, step)) { |
| 12868 | end = step = null; |
| 12869 | } |
| 12870 | start = +start || 0; |
| 12871 | step = step == null ? 1 : (+step || 0); |
| 12872 | |
| 12873 | if (end == null) { |
| 12874 | end = start; |
| 12875 | start = 0; |
| 12876 | } else { |
| 12877 | end = +end || 0; |
| 12878 | } |
| 12879 | // Use `Array(length)` so engines like Chakra and V8 avoid slower modes. |
| 12880 | // See https://youtu.be/XAqIpGU8ZZk#t=17m25s for more details. |
| 12881 | var index = -1, |
| 12882 | length = nativeMax(ceil((end - start) / (step || 1)), 0), |
| 12883 | result = Array(length); |
| 12884 | |
| 12885 | while (++index < length) { |
| 12886 | result[index] = start; |
| 12887 | start += step; |
| 12888 | } |
| 12889 | return result; |
| 12890 | } |
| 12891 | |
| 12892 | /** |
| 12893 | * Invokes the iteratee function `n` times, returning an array of the results |
no test coverage detected