Loops
/ API Reference
Loops
/ API Reference

arrayMap

Maps the array based on the provided mapper function.
Similar to Array.prototype.map.

The Gist

import { arrayMap } from '@weser/loops'

const mappedArray = arrayMap([1, 2, 3], (value) => value * 2)

// => [2, 4, 6]
console.log(mappedArray)

Parameters

ParameterTypeDescription
arrArray<T>The array to map.
mapper(value: T, index: number, length: number, array: Array<T>) => RThe mapper function.

Returns

(Array<R>) The mapped array.

On this page