Skip to content

Instantly share code, notes, and snippets.

@anshumanvenkatesh
Created February 18, 2019 07:22
Show Gist options
  • Select an option

  • Save anshumanvenkatesh/b939eaab100451cb0236f22a666697d7 to your computer and use it in GitHub Desktop.

Select an option

Save anshumanvenkatesh/b939eaab100451cb0236f22a666697d7 to your computer and use it in GitHub Desktop.

Revisions

  1. anshumanvenkatesh created this gist Feb 18, 2019.
    13 changes: 13 additions & 0 deletions invertsObject.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    const invertObject = x => {
    let sol = {}
    R.mapObjIndexed((val, key, obj) => {
    R.map(type => {
    if (type in sol) {
    sol[type].push(key);
    } else {
    sol[type] = [key]
    }
    })(val)
    }, x)
    return sol
    }