import { range } from "https://deno.land/x/proc@0.20.33/tools/deps/proc.ts";
Lazily create a range of numbers.
There are two forms:
- from/to/step:
to
is exclusive, and - from/until/step:
until
is inclusive.
Examples
to
is exclusive:
const result = await range({to: 3}).collect();
// [0, 1, 2]
until
is inclusive. from
starts at 0 by default.
const result = await range({from: 1, until: 3}).collect();
// [1, 2, 3]
step
can be negative. Default is 1.
const result = await range({from: -1, until: -3, step: -1}).collect();
// [-1, -2, -3]
Parameters
options: RangeToOptions | RangeUntilOptions
Range options.
Returns
Enumerable<number>