Repository URL to install this package:
|
Version:
6.0.4 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var size_1 = require("../../util/size");
var preAllocate_1 = require("../../array/preAllocate");
/**
* Creates an array of values by running each element of `array` thru `iteratee`.
* The iteratee is invoked with three arguments: (value, index, array).
* @memberOf loop
* @since 5.0.0-beta.6
*
* @name mapArray
* @alias mapArrayVals
*
* @param array The array to iterate over.
* @param iteratee The function invoked per iteration.
* @return Returns the new mapped array.
*
* @category Array
*
* {@link https://github.com/lodash/lodash/blob/master/map.js lodash-map}
* @see {@link lodash-map}
*
* @example
*
* const square = n => n * n
* mapArray([4, 8], square)
* //=> [16, 64]
*
*/
function mapArray(array, iteratee) {
var index = -1;
var length = size_1.default(array);
var result = preAllocate_1.default(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
exports.default = mapArray;
//# sourceMappingURL=mapArray.js.map