Function mapValues

  • Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru iteratee. The iteratee is invoked with three arguments: (value, key, object).

    Type Parameters

    • T

    Parameters

    • object: PlainObject<T>

      The object to iterate over.

    • iteratee: KeyIteratee

      The function invoked per iteration.

    Returns PlainObject

    Returns the new mapped object.

    Since

    5.11.0

    See

    [[mapKeys]]

    Example

    const users = {
    'fred': { 'user': 'fred', 'age': 40 },
    'pebbles': { 'user': 'pebbles', 'age': 1 }
    }

    mapValue(users, ({ age }) => age)
    // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  • Type Parameters

    • T

    Parameters

    • object: PlainObject<T>
    • iteratee: CollectionIteratee<T>

    Returns PlainObject