Numbers.range()
Syntax
Overload 1
function range(from: number, to: number): Range
Creates a new Range
from the two bounds.
Parameters | |
from
|
The left bound of the Range. This is not necessarily the smaller value. |
to
|
The right bound of the Range. This is not necessarily the larger value. |
Overload 2
function range(...values: number[]): Range
Creates a new Range
that spans all the numbers specified.
Parameters | |
values
Rest
|
All the values that the range should span. The range will be between the smallest and the largest element. Note that a range must have at least two bounds, so specifying less than two numbers here will result in an error, and if you specify exactly two numbers the other overload will be used instead (in which case, unlike here, the order of the arguments actually matters). |
Example
import { Numbers } from 'potence';
const range = Numbers.range(10, 5); // -> Range from 10 to 5 (inverted)
const range2 = Numbers.range(10, 2, 12, 0); // -> Range from 0 to 12
Remarks
Due to conflicts with the
Range
from lib.dom.d.ts
, you may wish to create a new range using this function
instead of using Range
’s constructor
directly.