Skip to content

Instantly share code, notes, and snippets.

@paulorsbrito
Last active November 19, 2018 12:45
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 paulorsbrito/2d74a8bf5368adddd6ec9d74dd055aa8 to your computer and use it in GitHub Desktop.
Save paulorsbrito/2d74a8bf5368adddd6ec9d74dd055aa8 to your computer and use it in GitHub Desktop.
Clone an object removing Firestore's stuffs from it
/**
* Clone an object removing Firestore's stuffs from it (ES7)
*
* @param {Object} obj - obj to work on
* @param {Array} ignoredProps - Additional props to ignore (always ignores "ref")
*/
export function unfirebased(obj, ignoredProps = []) {
ignoredProps = [...ignoredProps, 'ref']
return JSON.parse(JSON.stringify(obj, (key,value) => {
if (ignoredProps.find(item => item == key))
return undefined
return value
}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment