UNPKG

typedash

Version:

modern, type-safe collection of utility functions

23 lines (22 loc) 709 B
import { Writable } from "type-fest"; //#region src/functions/invert/invert.d.ts /** * Inverts the keys and values of an object. * @param object The object to invert. * @returns A new object with the keys and values inverted. * * If the object has duplicate values, the last key will be used. * @example * ```typescript * invert({ * a: 'x', * b: 'y', * c: 'z' * }); // { x: 'a', y: 'b', z: 'c' } * ``` */ declare function invert<const T extends Record<PropertyKey, PropertyKey>>(object: T): Writable<Inverted<T>>; type Inverted<T extends Record<PropertyKey, PropertyKey>> = { [K in keyof T as T[K]]: K }; //#endregion export { invert as t }; //# sourceMappingURL=invert-wkeiqjzz.d.cts.map