key-map
v1.0.0
Published
Keep track of old keys when removing duplicates.
Downloads
11
Maintainers
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.
Installing
npm install key-map
Usage
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.