adjust
Applies a function to the element at an index and returns a new array.
Usage
adjust(array, index, fn)
Use adjust when one position needs to change without mutating the input array. The callback runs only when index is within the array bounds; an out-of-bounds index returns an unchanged copy.
Parameters
arrayreadonly T[]required
the source array. It is never mutated.
indexnumberrequired
the zero-based index of the element to transform.
fn(value: T) => Trequired
the function applied to the element at index.
Returns
a new array containing the transformed element. When index is negative or greater than or equal to the array length, the returned copy has the same elements as array.