You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{objectEntries,objectFromEntries}from'ts-extras';/** * Creates an object composed of the inverted keys and values of `object`. * * Return type copied from https://stackoverflow.com/a/56416192 */exportconstinvertObject=<TObjectextendsRecord<string,string>,>(object: TObject,): {[PinkeyofTObjectasTObject[P]]: P;}=>{returnobjectFromEntries(objectEntries(object).map(([key,value])=>[value,key]),)asunknownas{[PinkeyofTObjectasTObject[P]]: P;};};
Activity
devinrhode2 commentedon May 8, 2023
Code sample provided without warranty