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.

Revisions

  1. marc-rutkowski created this gist Mar 12, 2016.
    8 changes: 8 additions & 0 deletions func.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    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;
    }, {});