Created
October 19, 2014 19:26
-
-
Save iskeld/ace7924025c3d5485090 to your computer and use it in GitHub Desktop.
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
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