Function mapObjectWith

Maps an object's values to a new set of values using a transformation function.

The type of the result is an object preserving the keys and inferring the type of each value based on the transformation function.

const obj = { a: 1, b: 2, c: 3 };
const double = (x: number) => x * 2;
const a = mapObjectWith(obj)(double); // { a: 2, b: 4, c: 6 }
// type { a: number, b: number, c: number }
  • Type Parameters

    • From
    • Source extends Record<string, From>

    Parameters

    Returns (<To>(transformation: ((x: Source[keyof Source]) => To)) => {
        [K in string | number | symbol]: To
    })

      • <To>(transformation): {
            [K in string | number | symbol]: To
        }
      • Type Parameters

        • To

        Parameters

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