Created
January 15, 2019 00:51
-
-
Save alex-cory/b9a6915d7c6b53901359a4fc779efac3 to your computer and use it in GitHub Desktop.
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
/** | |
* Only take the specified fields out of the object | |
*/ | |
const pick = (o, ...fields) => | |
fields.reduce((acc, x) => { | |
if ((o || {}).hasOwnProperty(x)) { | |
acc[x] = o[x]; | |
} | |
return acc; | |
}, {}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment