mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 07:17:50 +00:00
21 lines
507 B
JavaScript
21 lines
507 B
JavaScript
/**
|
|
* A specialized version of `map` for arrays.
|
|
*
|
|
* @private
|
|
* @param {Array} [array] The array to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Array} Returns the new mapped array.
|
|
*/
|
|
function arrayMap(array, iteratee) {
|
|
let index = -1
|
|
const length = array == null ? 0 : array.length
|
|
const result = Array(length)
|
|
|
|
while (++index < length) {
|
|
result[index] = iteratee(array[index], index, array)
|
|
}
|
|
return result
|
|
}
|
|
|
|
export default arrayMap
|