Skip to content

Instantly share code, notes, and snippets.

@iskeld
Created October 19, 2014 19:26
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 iskeld/ace7924025c3d5485090 to your computer and use it in GitHub Desktop.
Save iskeld/ace7924025c3d5485090 to your computer and use it in GitHub Desktop.
function isCustomObject(obj) {
var result = obj && Object.prototype.toString.call(obj) == '[object Object]';
return result;
}
function deepOmit(obj) {
var newEntity = _.transform(obj, function(result, value, key) {
console.log(value.constructor.name);
var isParentProperty = String(key).toLowerCase().indexOf("parent") >= 0;
if (!isParentProperty) {
if (_.isArray(value) || isCustomObject(value)) {
result[key] = deepOmit(value);
}
else {
result[key] = value;
}
}
});
return newEntity;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment