Repository URL to install this package:
|
Version:
6.0.4 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var preAllocate_1 = require("../../array/preAllocate");
/**
* The opposite of `mapValue` this method creates an ARRAY with the
* same values as `ARRAY` and keys generated by running each own enumerable
* string keyed property of `ARRAY` thru `iteratee`. The iteratee is invoked
* with three arguments: (value, key, ARRAY).
* @since 5.0.0-beta.6
* @memberOf loop
* @alias mapArrayIndex
* @alias mapArrayIndexes
* @alias mapIndex
*
* @param array The array to iterate over.
* @param iteratee The function invoked per iteration.
* @return Returns the new mapped ARRAY.
*
* @fork 3.8.0
* @category Array
*
* @see mapValue
*
* @example
*
* mapKey({ 'a': 1, 'b': 2 }, (value, key) => key + value)
* //=> { 'a1': 1, 'b2': 2 }
*
*/
function mapIndex(
/**
* is actually the obj
*/
array, iteratee) {
// const arr = toArray(array)
var result = preAllocate_1.default(array);
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
var key = array_1[_i];
var value = array[key];
result[iteratee(value, key, array)] = value;
}
return result;
}
exports.default = mapIndex;
//# sourceMappingURL=mapArrayKeys.js.map