Skip to content

Instantly share code, notes, and snippets.

@JonathonAshworth
Last active January 5, 2020 02:56
Show Gist options
  • Select an option

  • Save JonathonAshworth/913c772ca15268731aa1f21c40a3fcea to your computer and use it in GitHub Desktop.

Select an option

Save JonathonAshworth/913c772ca15268731aa1f21c40a3fcea to your computer and use it in GitHub Desktop.
Object Utilities
// f of the form (k, v) => v
export const objMap = (obj, f) =>
Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, f(k, v)]));
// f of the form ([k, v]) => [k, v]
export const objMapEntries = (obj, f) =>
Object.fromEntries(Object.entries(obj).map(f));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment