source: node_modules/es-toolkit/dist/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: 485 bytes
Line 
1function rangeRight(start, end, step = 1) {
2 if (end == null) {
3 end = start;
4 start = 0;
5 }
6 if (!Number.isInteger(step) || step === 0) {
7 throw new Error(`The step value must be a non-zero integer.`);
8 }
9 const length = Math.max(Math.ceil((end - start) / step), 0);
10 const result = new Array(length);
11 for (let i = 0; i < length; i++) {
12 result[i] = start + (length - i - 1) * step;
13 }
14 return result;
15}
16
17export { rangeRight };
Note: See TracBrowser for help on using the repository browser.