I need to find the fastest way to remove all $meta
properties and their values from an object, for example:
{
\"part_one\": {
\"name\": \"
// recursively delete a key from anywhere in the object
// will mutate the obj - no need to return it
const deletePropFromObj = (obj, deleteThisKey) => {
if (Array.isArray(obj)) {
obj.forEach(element => deletePropFromObj(element, deleteThisKey))
} else if (typeof obj === 'object') {
for (const key in obj) {
const value = obj[key]
if (key === deleteThisKey) delete obj[key]
else deletePropFromObj(value, deleteThisKey)
}
}
}
deletePropFromObj(obj, '$meta');