|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
768 bytes
|
| Line | |
|---|
| 1 | import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
|
|---|
| 2 | import { toFinite } from '../util/toFinite.mjs';
|
|---|
| 3 |
|
|---|
| 4 | function rangeRight(start, end, step) {
|
|---|
| 5 | if (step && typeof step !== 'number' && isIterateeCall(start, end, step)) {
|
|---|
| 6 | end = step = undefined;
|
|---|
| 7 | }
|
|---|
| 8 | start = toFinite(start);
|
|---|
| 9 | if (end === undefined) {
|
|---|
| 10 | end = start;
|
|---|
| 11 | start = 0;
|
|---|
| 12 | }
|
|---|
| 13 | else {
|
|---|
| 14 | end = toFinite(end);
|
|---|
| 15 | }
|
|---|
| 16 | step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
|
|---|
| 17 | const length = Math.max(Math.ceil((end - start) / (step || 1)), 0);
|
|---|
| 18 | const result = new Array(length);
|
|---|
| 19 | for (let index = length - 1; index >= 0; index--) {
|
|---|
| 20 | result[index] = start;
|
|---|
| 21 | start += step;
|
|---|
| 22 | }
|
|---|
| 23 | return result;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | export { rangeRight };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.