| 1 |
/* Built-in method references for those with the same name as other `lodash` methods. */ |
| 2 |
var nativeCeil = Math.ceil, |
| 3 |
nativeMax = Math.max; |
| 4 |
|
| 5 |
/** |
| 6 |
* The base implementation of `_.range` and `_.rangeRight` which doesn't |
| 7 |
* coerce arguments. |
| 8 |
* |
| 9 |
* @private |
| 10 |
* @param {number} start The start of the range. |
| 11 |
* @param {number} end The end of the range. |
| 12 |
* @param {number} step The value to increment or decrement by. |
| 13 |
* @param {boolean} [fromRight] Specify iterating from right to left. |
| 14 |
* @returns {Array} Returns the range of numbers. |
| 15 |
*/ |
| 16 |
function baseRange(start, end, step, fromRight) { |
| 17 |
var index = -1, |
| 18 |
length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), |
| 19 |
result = Array(length); |
| 20 |
|
| 21 |
while (length--) { |
| 22 |
result[fromRight ? length : ++index] = start; |
| 23 |
start += step; |
| 24 |
} |
| 25 |
return result; |
| 26 |
} |
| 27 |
|
| 28 |
module.exports = baseRange; |