Skip to content

Instantly share code, notes, and snippets.

@fauxsaurus
Created December 19, 2020 20:54
Show Gist options
  • Save fauxsaurus/1d071af186044aa001ee4c844b885cbe to your computer and use it in GitHub Desktop.
Save fauxsaurus/1d071af186044aa001ee4c844b885cbe to your computer and use it in GitHub Desktop.
Object Utils
const renameObjKey = <T extends Record<string, any>>(
oldKey: string,
newKey: string,
{[oldKey]: value, ...obj}: T,
) => Object.assign({[newKey]: value}, obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment