Skip to content

Instantly share code, notes, and snippets.

@rmrotek
Created October 26, 2018 23:43
Show Gist options
  • Select an option

  • Save rmrotek/b3423b54a3f7a15755a900a2e08feaf0 to your computer and use it in GitHub Desktop.

Select an option

Save rmrotek/b3423b54a3f7a15755a900a2e08feaf0 to your computer and use it in GitHub Desktop.
export const mapObjectToArray = (obj) => (
Object.entries(obj || {})
.map(([key, value]) => (
typeof value === 'object' && !(value instanceof Array) ?
{ ...value, key }
:
{ key, value }
))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment