https://github.com/derhuerst/key-map
Keep track of old keys when removing duplicates.
https://github.com/derhuerst/key-map
duplicates object rename
Last synced: 4 months ago
JSON representation
Keep track of old keys when removing duplicates.
- Host: GitHub
- URL: https://github.com/derhuerst/key-map
- Owner: derhuerst
- License: isc
- Created: 2016-04-20T14:34:20.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-05-03T15:54:37.000Z (about 6 years ago)
- Last Synced: 2025-02-09T16:39:02.025Z (over 1 year ago)
- Topics: duplicates, object, rename
- Language: JavaScript
- Homepage: https://github.com/derhuerst/key-map
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# key-map 🔜
**When you remove duplicates in a collection** mapped by keys, you may want to **keep track of old keys** and their new equivalent.
[](https://www.npmjs.com/package/key-map)
[](https://travis-ci.org/derhuerst/key-map)
[](https://david-dm.org/derhuerst/key-map)
[](https://david-dm.org/derhuerst/key-map#info=devDependencies)

[](https://gitter.im/derhuerst)
## Installing
```
npm install key-map
```
## Usage
```js
const keyMap = require('key-map')
const m = keyMap(['a', 'b', 'c'])
m.get('a') // -> 'a'
m.get('b') // -> 'b'
m.get('c') // -> 'c'
m.map('c', 'b') // map c to b
m.map('b', 'a') // map b to a
m.get('a') // -> 'a'
m.get('b') // -> 'a'
m.get('c') // -> 'a'
```
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/key-map/issues).