Created
September 10, 2019 14:57
-
-
Save MateusAndrade/bf9f5595f7b005865b476111eac8d7c9 to your computer and use it in GitHub Desktop.
A simple function to remove obj keys
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 characters
const removeObjKeys: <T>(obj: T, keys: string[]) => T = (obj, keys) => { | |
const objectKeys: string[] = Object.keys(obj); | |
keys.forEach((key: string) => { | |
const isPresentKey = objectKeys.find((objKey: string) => objKey === key); | |
if (isPresentKey) { | |
delete obj[key]; | |
} | |
}); | |
return obj; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment