Skip to content

Instantly share code, notes, and snippets.

@wholypantalones
Last active April 18, 2019 14:46
Show Gist options
  • Save wholypantalones/992066990aedda94fcc023944cef13e8 to your computer and use it in GitHub Desktop.
Save wholypantalones/992066990aedda94fcc023944cef13e8 to your computer and use it in GitHub Desktop.
TypeScript params obj from obj
/**
* loop through the config obj and delete the things we do not need
* to make a params obj from the config obj
*/
static objFromConfig(params) {
const newObj = JSON.parse(JSON.stringify(params));
Object.entries(newObj).map(([k, v]) => {
if (v === null || v === '') {
delete newObj[k];
}
});
return newObj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment