An open API service indexing awesome lists of open source software.

https://github.com/pana/two-way-map

JS object get value by key, and also key by value
https://github.com/pana/two-way-map

Last synced: 7 months ago
JSON representation

JS object get value by key, and also key by value

Awesome Lists containing this project

README

          

twoWayMap
=====
Object get value by key, or get key by value.

## Install
```
$ npm install two-way-map
```

## How to use

```js
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