Skip to content

Instantly share code, notes, and snippets.

@gabmontes
Created January 12, 2017 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabmontes/e6bf5dccce76843bb278b9e89ac9e19f to your computer and use it in GitHub Desktop.
Save gabmontes/e6bf5dccce76843bb278b9e89ac9e19f to your computer and use it in GitHub Desktop.
const mapFields = (obj, map) =>
Object.keys(map)
.map(key => ({ key, value: obj[map[key]] }))
.reduce((res, { key, value }) => Object.assign(res, { [key]: value }), {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment