UNPKG

typedash

Version:

modern, type-safe collection of utility functions

17 lines (14 loc) 821 B
import { C as CastToString } from '../CastToString-BoaHrryS.js'; import { K as KeysOfUnion } from '../KeysOfUnion-BrkZWXzm.js'; /** * Returns a new object with the same keys as the given object, but with each value mapped to a new value as returned by the given mapper function. * @param object The object to map. * @param mapperFunction The function used to map each value. * @returns A new object with the same keys as the given object, but with each value mapped to a new value as returned by the given mapper function. * @example * ```ts * mapValues({ a: 1, b: 2, c: 3 }, (value) => value * 2) // { a: 2, b: 4, c: 6 } * ``` */ declare function mapValues<T extends object, V>(object: T, mapperFunction: (value: T[keyof T], key: CastToString<KeysOfUnion<T>>) => V): Record<keyof T, V>; export { mapValues };