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
// A SO answer to https://stackoverflow.com/questions/286141/remove-blank-attributes-from-an-object-in-javascript | |
// based off the recursive cleanEmpty function by @chickens. | |
// This one can also handle Date objects correctly | |
// and has a defaults list for values you want stripped. | |
const cleanEmpty = function(obj, defaults = [undefined, null, NaN, '']) { | |
if (defaults.includes(obj)) return | |
if (Array.isArray(obj)) | |
return obj |