source: node_modules/es-toolkit/dist/compat/math/rangeRight.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 768 bytes
RevLine 
[a762898]1import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
2import { toFinite } from '../util/toFinite.mjs';
3
4function 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
26export { rangeRight };
Note: See TracBrowser for help on using the repository browser.