Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/object/mapValues

Index

Functions

Functions

Const mapValues

  • mapValues<T, K>(object: T, mapper: (value: T[keyof T], key: string, obj: T) => K): Record<keyof T, K>
  • Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru mapper.

    example

    var users = {'fred':{ 'user': 'fred', 'age': 40 }, 'pebbles': { 'user': 'pebbles', 'age': 1 }} mapValues(users, o => o.age); // returns { 'fred': 40, 'pebbles': 1 }

    Type parameters

    • T

    • K

    Parameters

    • object: T
    • mapper: (value: T[keyof T], key: string, obj: T) => K
        • (value: T[keyof T], key: string, obj: T): K
        • Parameters

          • value: T[keyof T]
          • key: string
          • obj: T

          Returns K

    Returns Record<keyof T, K>

Generated using TypeDoc