Loops
/ API ReferenceLoops
/ API ReferencearrayMap
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
Parameter | Type | Description |
---|---|---|
arr | Array<T> | The array to map. |
mapper | (value: T, index: number, length: number, array: Array<T>) => R | The mapper function. |
Returns
(Array<R>
) The mapped array.
© 2024-present Robin Weser. All Rights Reserved.