@nevware21/ts-utils
    Preparing search index...

    Function objMapValues

    • Creates a new object with the same keys as source but with each value transformed by the provided mapper function.

      Type Parameters

      • T

        The type of the source object

      • U

        The type of the mapped values

      Parameters

      • source: T

        The source object whose values will be mapped

      • mapper: (value: T[keyof T], key: PropertyKey) => U

        A function (value, key) => U called for every own enumerable property.

      Returns { [K in string | number | symbol]: U }

      A new object with the same keys as source and values produced by mapper. Returns an empty object if source is null or undefined.

      0.14.0

      const prices = { apple: 1.5, banana: 0.75, cherry: 3.0 };

      objMapValues(prices, (v) => v * 2);
      // => { apple: 3, banana: 1.5, cherry: 6 }

      const user = { firstName: "ada", lastName: "lovelace" };
      objMapValues(user, (v) => v.toUpperCase());
      // => { firstName: "ADA", lastName: "LOVELACE" }