mapRight
A function that iterates over each element of the given array from right to left, calls the provided callback function, and returns the results as a new array.
Code
Interface
typescript
function mapRight<T, U>(
arr: T[] | readonly T[],
callback: (currentValue: T, index: number, arr: T[] | readonly T[]) => U,
): U[];
Usage
typescript
import { mapRight } from '@modern-kit/utils';
mapRight([1, 2, 3], (item, index) => item + index);
// [5, 3, 1]