Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 6 days 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 (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-03T15:54:37.000Z (over 4 years ago)
- Last Synced: 2024-10-03T23:57:54.550Z (about 1 month 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.
[![npm version](https://img.shields.io/npm/v/key-map.svg)](https://www.npmjs.com/package/key-map)
[![build status](https://img.shields.io/travis/derhuerst/key-map.svg)](https://travis-ci.org/derhuerst/key-map)
[![dependency status](https://img.shields.io/david/derhuerst/key-map.svg)](https://david-dm.org/derhuerst/key-map)
[![dev dependency status](https://img.shields.io/david/dev/derhuerst/key-map.svg)](https://david-dm.org/derhuerst/key-map#info=devDependencies)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/key-map.svg)
[![chat on gitter](https://badges.gitter.im/derhuerst.svg)](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 am.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).