Last active
April 18, 2019 14:46
-
-
Save wholypantalones/992066990aedda94fcc023944cef13e8 to your computer and use it in GitHub Desktop.
TypeScript params obj from obj
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
/** | |
* 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