range (for BigInts) es-toolkit
Returns an array of BigInts counting from a start value up to, but not including, an end value.
This function is available exclusively from es-toolkit/bigint to avoid potential conflicts with similar functions for other numeric types.
Usage
range(end)
Use range with one argument to count from 0n up to, but not including, the end value.
Parameters
The end of the range, exclusive.
Returns
Returns an array of BigInts from 0n up to, but not including, end.
range(start, end)
Use range with two arguments to count from a start value instead of 0n.
Because BigInts stay exact at any size, you can build ranges past Number.MAX_SAFE_INTEGER without values silently colliding.
Parameters
The start of the range, inclusive.
The end of the range, exclusive.
Returns
Returns an array of BigInts from start up to, but not including, end.
range(start, end, step)
Use range with three arguments to count by something other than 1n. A negative step counts down.
If the step points away from the end value, there is nothing to produce and you get an empty array.
Parameters
The start of the range, inclusive.
The end of the range, exclusive.
The amount to count by. Defaults to 1n.
Returns
Returns an array of BigInts from start up to, but not including, end, counting by step.
Throws
Throws an error if step is 0n.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.