source: node_modules/es-toolkit/dist/math/range.js@ a762898

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

Added visualizations

  • Property mode set to 100644
File size: 554 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5function range(start, end, step = 1) {
6 if (end == null) {
7 end = start;
8 start = 0;
9 }
10 if (!Number.isInteger(step) || step === 0) {
11 throw new Error(`The step value must be a non-zero integer.`);
12 }
13 const length = Math.max(Math.ceil((end - start) / step), 0);
14 const result = new Array(length);
15 for (let i = 0; i < length; i++) {
16 result[i] = start + i * step;
17 }
18 return result;
19}
20
21exports.range = range;
Note: See TracBrowser for help on using the repository browser.