Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
chain-able-deps / dist / loop / map / mapArray.js
Size: Mime:
"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