Created
March 9, 2016 16:44
-
-
Save PizzaBrandon/3afcad8d71a13179272a to your computer and use it in GitHub Desktop.
omitDeep.js
This file contains 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
// 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