Last active
January 23, 2017 19:26
-
-
Save marc-rutkowski/e671ebbb4563af0a1c4c to your computer and use it in GitHub Desktop.
ES6 func
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
const isUnique = (value, index, self) => self.indexOf(value) === index; | |
const unique = items => items.filter(isUnique); | |
const mapBy = (items, key) => items.map(item => item[key]); | |
const uniqueKeys = (items, key) => unique(mapBy(items, key)); | |
const someKeys = (item, keys) => keys.reduce((result, key) => { | |
result[key] = item[key]; | |
return result; | |
}, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment