Skip to content

Instantly share code, notes, and snippets.

@marc-rutkowski
Last active January 23, 2017 19:26
Show Gist options
  • Save marc-rutkowski/e671ebbb4563af0a1c4c to your computer and use it in GitHub Desktop.
Save marc-rutkowski/e671ebbb4563af0a1c4c to your computer and use it in GitHub Desktop.
ES6 func
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