mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Remove baseIteratee and castFunction.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import baseAssignValue from './_baseAssignValue.js';
|
||||
import baseForOwn from './_baseForOwn.js';
|
||||
import baseIteratee from './_baseIteratee.js';
|
||||
|
||||
/**
|
||||
* Creates an object with the same keys as `object` and values generated
|
||||
@@ -13,7 +12,7 @@ import baseIteratee from './_baseIteratee.js';
|
||||
* @since 2.4.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @param {Function} iteratee The function invoked per iteration.
|
||||
* @returns {Object} Returns the new mapped object.
|
||||
* @see _.mapKeys
|
||||
* @example
|
||||
@@ -25,15 +24,9 @@ import baseIteratee from './_baseIteratee.js';
|
||||
*
|
||||
* _.mapValues(users, function(o) { return o.age; });
|
||||
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.mapValues(users, 'age');
|
||||
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
||||
*/
|
||||
function mapValues(object, iteratee) {
|
||||
const result = {};
|
||||
iteratee = baseIteratee(iteratee, 3);
|
||||
|
||||
baseForOwn(object, (value, key, object) => {
|
||||
baseAssignValue(result, key, iteratee(value, key, object));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user