Created
April 5, 2020 07:13
-
-
Save jmorenoamor/432f4b9dd709dc2f5b3d4153e9c98a00 to your computer and use it in GitHub Desktop.
Removes all the occurences of a particular property from an object
This file contains hidden or 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
/* | |
* Removes all the occurences of a particular property from an object | |
*/ | |
function stripeObject(obj, property="_meta") { | |
Object.keys(obj).forEach(k => { | |
if (typeof obj === "object") { | |
if (k === property) { | |
delete obj[k]; | |
} else { | |
obj[k] = stripeObject(obj[k]); | |
} | |
} | |
}); | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment