main
Last change
on this file since 0c6b92a was d565449, checked in by stefan toskovski <stefantoska84@…>, 3 months ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
848 bytes
|
Rev | Line | |
---|
[d565449] | 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 | export default baseRange;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.