Skip to main content


Produces a new array of values by mapping each value in the supplied array, collection or enumerable object through a transformation function.


map<T, R>(
list: TList<T> | undefined,
fn: (item: T, ...arguments: any[]) => R,
...arguments: any[]
): R[]


listT[] | undefinedNoSpecifies the array, collection or enumerable object to iterate through.
fn(...arguments: any[]) => T | voidNoSpecifies the function to be invoked for each element. The element value will be exposed to the function as the first argument of the argument list. Additional arguments can be specified and will be pushed to the function.
argumentsany[]YesOptional arguments which should be passed to the callee.

Return value

Returns an array with mapped values.


import { map } from "@tripetto/builder";

map<number, number>([1, 2, 3], (nItem: number) => nItem * nItem); // Returns `[1, 4, 9]`
map<number, number>([1, 2, 3], (nItem: number, nMultiplier: number) => nItem * nMultiplier, 2); // Returns `[2, 4, 6]`