Skip to content

Instantly share code, notes, and snippets.

@anshumanvenkatesh
Created February 18, 2019 07:22
Show Gist options
  • Save anshumanvenkatesh/b939eaab100451cb0236f22a666697d7 to your computer and use it in GitHub Desktop.
Save anshumanvenkatesh/b939eaab100451cb0236f22a666697d7 to your computer and use it in GitHub Desktop.
Inverts an object
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment