invert-object

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

npm install invert-object
2 downloads in the last week
5 downloads in the last month

invert-object

Usage

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

Example


var assert = require('assert')

  , invertObject = require('invert-object')

  , inverted = invertObject({foo: '1', bar: 1})

assert.deepEqual(inverted, {1: ['foo', 'bar']})
npm loves you