UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

14 lines (13 loc) 437 B
/** * Generates a range of numbers from start to end (inclusive). * @param {number} start - The starting number of the range. * @param {number} end - The ending number of the range. * @returns An array of numbers from start to end. * @example * range(1, 5); // [1, 2, 3, 4, 5] */ export function range(start, end) { if (start === end) return [start]; return Array.from({ length: end - start + 1 }, (_, i) => i); }