UNPKG

typedash

Version:

modern, type-safe collection of utility functions

26 lines (24 loc) 864 B
//#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 Object.defineProperty(exports, 'range', { enumerable: true, get: function () { return range; } }); //# sourceMappingURL=range-fwApDQux.cjs.map