The number of elements to include in the range
An array of numbers from 0 to count-1
import { range } from '@consumidor-positivo/ts-utils';
// Create an array from 0 to 4
const numbers = range(5); // [0, 1, 2, 3, 4]
// Use with map to generate a sequence
const doubledNumbers = range(3).map(n => n * 2); // [0, 2, 4]
// Create a range for iteration
for (const i of range(3)) {
console.log(i); // Logs 0, 1, 2
}
Creates an array of sequential numbers from 0 to n-1.
This utility function is useful for generating sequential number arrays that can be used for iterations, mappings, or creating numeric sequences.