two-way-map
v0.3.0
Published
Get value from key, and in reverse
Downloads
2
Readme
twoWayMap
Object get value by key, or get key by value.
Install
$ npm install two-way-map
How to use
var mapper = {
"regist": 1,
"login": 2,
"update": 3
};
var twoMap = require('two-way-map');
twoMap(mapper, "regist") // 1
twoMap(mapper, 1) // regist
Notice:
- When try to get key by value, use == test
- Get key by value the result is an string, so you should only use string as mapper's key