js-util

Home > rc-js-util > arrayMapRange

arrayMapRange() function

Like arrayMap() with integer range as input.

Signature:

export declare function arrayMapRange<TMapped>(from: number, to: number, callback: (value: number, index: number) => TMapped): TMapped[];

Parameters

Parameter Type Description
from number The value to start from (inclusive).
to number The value to finish with (inclusive).
callback (value: number, index: number) => TMapped Called for each value in the range.

Returns:

TMapped[]

An array of results from the callback.

Remarks

Where from and to are equal a length 1 array is returned, NaN input is not supported.

See arrayMapRange().