UNPKG

typedash

Version:

modern, type-safe collection of utility functions

29 lines (27 loc) 657 B
//#region src/functions/invert/invert.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' } * ``` */ function invert(object) { return Object.fromEntries(Object.entries(object).map(([key, value]) => [value, key])); } //#endregion Object.defineProperty(exports, 'invert', { enumerable: true, get: function () { return invert; } }); //# sourceMappingURL=invert-CcmATa3k.cjs.map