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
- Host: GitHub
- URL: https://github.com/pana/two-way-map
- Owner: Pana
- Created: 2016-03-25T09:40:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-25T09:59:29.000Z (over 9 years ago)
- Last Synced: 2025-01-28T21:47:16.761Z (9 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
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