invert-object

Invert a javascript object so that keys are values and values are keys

invert-object

Invert an object so that keys becomes values and values become keys. Duplicate values in input is allowed by puttin all keys in arrays.

 
var assert = require('assert')
 
  , invertObject = require('invert-object')
 
  , inverted = invertObject({foo: '1', bar: 1})
 
assert.deepEqual(inverted, {1: ['foo', 'bar']})