Skip to content

Instantly share code, notes, and snippets.

@marr
Last active August 29, 2015 14:22
Show Gist options
  • Save marr/c40079597f1f7650b904 to your computer and use it in GitHub Desktop.
Save marr/c40079597f1f7650b904 to your computer and use it in GitHub Desktop.
// true if any objects values are truthy
function any(object) {
return Object.keys(object).some(k => !!object[k]);
}
// filter empty values from object and return filtered object
function filterObject(object) {
if (object) {
const filteredObject = {};
Object.keys(object).forEach(k => {
if (any(object[k])) {
filteredObject[k] = object[k];
};
});
return filteredObject;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment