Range

The Range class provides utility methods for working with numeric ranges. It allows you to generate a range of numbers, check if a value is within a specified range, and create aliases for the range methods.

Example Usage
rangeTo(0,10,3)
    .forEach(it => console.log(`Index: ${it}`));
// Output:
//    Index: 0
//    Index: 3
//    Index: 6
//    Index: 9

Functions

rangeTo

Creates an array representing a range of numbers from start to end (inclusive) with an optional step.

const numericRange = rangeTo(1, 5, 2);
console.log(numericRange); // Output: [1, 3, 5]

rangeUntil

Creates an array representing a range of numbers from start to (end - 1) with an optional step.

const numericRange = rangeUntil(1, 5, 2);
console.log(numericRange); // Output: [1, 3]

inRange

Checks if a value is within the specified numeric range.

const isInRange = inRange(3, 1, 5);
console.log(isInRange); // Output: true

Last updated