GuobaGuoba Utils

invert

@guoba-ai/utils / object / invert

Function: invert()

function invert<T>(obj): Record<string, string>;

Defined in: object.ts:175

Swap the keys and values of an object.

Type Parameters

T

T extends Record<string, string | number | symbol>

Parameters

obj

T

The object to invert

Returns

Record<string, string>

A new object with keys and values swapped

Example

invert({ a: '1', b: '2' }) // { '1': 'a', '2': 'b' }

On this page