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.

    5.11.0

    [[mapKeys]]

    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)
  • 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: CollectionIteratee<T>

      The function invoked per iteration.

    Returns PlainObject

    Returns the new mapped object.

    5.11.0

    [[mapKeys]]

    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)