Last active
November 19, 2018 12:45
-
-
Save paulorsbrito/2d74a8bf5368adddd6ec9d74dd055aa8 to your computer and use it in GitHub Desktop.
Clone an object removing Firestore's stuffs from it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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