ok-tools
Version:
My personal JS tools and utilities
22 lines • 590 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.range = void 0;
function range(from, to, step) {
if (step === void 0) { step = 1; }
if (to === undefined) {
to = from - 1;
from = 0;
step = 1;
}
if (from > to) {
throw new Error('[from] must be less than [to]');
}
var count = Math.floor((to - from) / step);
var a = Array(count);
for (var i = from, index = 0; i <= to; i += step, index++) {
a[index] = i;
}
return a;
}
exports.range = range;
//# sourceMappingURL=range.js.map