typedash
Version:
modern, type-safe collection of utility functions
20 lines (19 loc) • 776 B
JavaScript
//#region src/functions/range/range.ts
/**
* Implementation for all overloads.
* @param startOrEnd The start value of the range, or the end value of the range if the `end` parameter is specified.
* @param end The end value of the range.
* @param step The step between each value in the range.
* @returns An array of numbers from the specified start value to the specified end value (exclusive).
*/
function range(startOrEnd, end, step = 1) {
if (step <= 0) return [];
const calculatedStart = end == null ? 0 : startOrEnd;
const calculatedEnd = end ?? startOrEnd;
const result = [];
for (let index = calculatedStart; index < calculatedEnd; index += step) result.push(index);
return result;
}
//#endregion
export { range as t };
//# sourceMappingURL=range-DrqAmJ3J.js.map