Last active
August 29, 2015 14:16
-
-
Save shaundon/bb5e68cb0f926c538be7 to your computer and use it in GitHub Desktop.
Revisions
-
shaundon revised this gist
Mar 2, 2015 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,14 +7,14 @@ var deepOmit = function(input, propertyToRemove) { }); } else if (_.isObject(input)) { output = {}; _.each(_.keys(input), function(key) { if (key !== propertyToRemove) { output[key] = deepOmit(input[key], propertyToRemove); } }); } return output; } /* -
shaundon revised this gist
Mar 2, 2015 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ var deepOmit = function(input, propertyToRemove) { var output = input; if (_.isArray(input)) { output = []; _.each(input, function(arrayItem) { @@ -14,9 +14,6 @@ var deepOmit = function(input, propertyToRemove) { } }); } return output; } -
shaundon revised this gist
Mar 2, 2015 . 1 changed file with 51 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,4 +18,54 @@ var deepOmit = function(input, propertyToRemove) { output = input; } return output; } /* EXAMPLE: deepOmit([ { a: true, remove: true }, { a: true, remove: true, b: { a: true, remove: true, c: { a: [ { a: true, remove: true } ] } } } ], 'remove'); WILL PRODUCE: [ { a: true }, { a: true, b: { a: true, c: { a: [ { a: true } ] } } } ] */ -
shaundon created this gist
Mar 2, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ var deepOmit = function(input, propertyToRemove) { var output = null; if (_.isArray(input)) { output = []; _.each(input, function(arrayItem) { output.push(deepOmit(arrayItem, propertyToRemove)); }); } else if (_.isObject(input)) { output = {}; _.each(_.keys(input), function(key) { if (key !== propertyToRemove) { output[key] = deepOmit(input[key], propertyToRemove); } }); } else { output = input; } return output; }