Created
March 16, 2019 20:35
-
-
Save DmitrySoshnikov/a0ce221eb2419923e46f0dc5a7e9d684 to your computer and use it in GitHub Desktop.
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
/** | |
* Filter object properties. | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
* MIT Style license, 2019 | |
*/ | |
const filterProps = ( | |
[p1, p2, p3], | |
{ | |
[p1]: _p1, | |
[p2]: _p2, | |
[p3]: _p3, | |
...toKeep | |
} | |
) => toKeep; | |
const data = { | |
password: 'querty', | |
accessToken: 'secret', | |
userID: 13, | |
userName: 'Yrtimd' | |
}; | |
const dataToLog = filterProps( | |
['password', 'accessToken'], | |
data, | |
); | |
console.log(dataToLog); // {userID: 13, userName: 'Yrtimd'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment