Skip to content

Instantly share code, notes, and snippets.

@PizzaBrandon
Created March 9, 2016 16:44
Show Gist options
  • Save PizzaBrandon/3afcad8d71a13179272a to your computer and use it in GitHub Desktop.
Save PizzaBrandon/3afcad8d71a13179272a to your computer and use it in GitHub Desktop.
omitDeep.js
// Depends on lodash.cloneDeepWith
// This example assumes excludeKeys is an array
function omitDeep(collection, excludeKeys) {
function omitFn(value) {
if (value && typeof value === 'object') {
excludeKeys.forEach((key) => {
delete value[key];
});
}
}
return _.cloneDeepWith(collection, omitFn);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment