rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
21 lines (20 loc) • 624 B
text/typescript
import { arrayMapRange } from "./array-map-range.js";
import { fpIdentity } from "../../fp/impl/fp-identity.js";
/**
* @public
* Generates a range of integers output in an `Array`.
*
* @param from - The value to start from (inclusive).
* @param to - The value to finish with (inclusive).
*
* @returns An array [from, from + 1, ..., to -1, to].
*
* @remarks
* Where `from` and `to` are equal a length 1 array is returned, NaN input is not supported.
*
* See {@link arrayGenerateRange}.
*/
export function arrayGenerateRange(from: number, to: number): number[]
{
return arrayMapRange(from, to, fpIdentity);
}