Created
April 30, 2019 12:41
-
-
Save radu-cojocaru/af93a22f7bfad793e29951e3ce437240 to your computer and use it in GitHub Desktop.
Javascript Utils
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
// Create a new object with a subset of fields - it's useful in react-redux' connect() | |
// pick('name')({name: 'John', age: 35}) => {name: 'John'} | |
export const pick = (...fields) => o => fields.reduce((result, field) => { | |
result[field] = o[field]; | |
return result; | |
}, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment