Skip to content

Instantly share code, notes, and snippets.

@panayotoff
Created January 13, 2017 13:47
Show Gist options
  • Save panayotoff/e8ddd15f2c5a901bc08c6a1ee16f35c9 to your computer and use it in GitHub Desktop.
Save panayotoff/e8ddd15f2c5a901bc08c6a1ee16f35c9 to your computer and use it in GitHub Desktop.
ES6 firebase object to array
/*
* Converts firebase object to Array;
* Each object from the array will contain 'key' property,
* corresponding to the firebase key
* */
const toArray = function (firebaseObj) {
return Object.keys(firebaseObj).map((key)=> {
return Object.assign(firebaseObj[key], {key});
})
};
export {toArray}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment