Skip to main content

reverseKeyValue

Returns an object in the form of { [value]: key } by swapping key and value

function reverseKeyValue<KeyType extends string, ValueType extends string>(
obj: Record<KeyType, ValueType>
): Record<ValueType, KeyType>;

Example

reverseKeyValue({ jbee: 'eebj' });
// => { eebj: 'jbee' }