Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/invert-hash
Inverts an object hash
https://github.com/mikolalysenko/invert-hash
Last synced: about 2 months ago
JSON representation
Inverts an object hash
- Host: GitHub
- URL: https://github.com/mikolalysenko/invert-hash
- Owner: mikolalysenko
- License: mit
- Created: 2013-04-16T17:13:33.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-05-14T00:12:24.000Z (over 11 years ago)
- Last Synced: 2024-10-20T14:27:43.521Z (2 months ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
invert-hash
===========
Computes the inverse of a hash, assuming that it is bijective.# Example
```javascript
var invert = require("invert-hash")
console.log(invert({
'a': 1,
'b': 2,
'c': 3
}))//Prints out:
//
// {
// 1: 'a',
// 2: 'b',
// 3: 'c'
// }
//
```# Install
npm install invert-hash
### `require("invert-hash")(obj)`
Computes the inverse of a hash* `obj` is a hash object
**Returns** An object whose keys are the values of `obj` and whose values are the `keys` of object.
# Credits
(c) 2013 Mikola Lysenko. MIT License