Skip to content

Keep track of old keys when removing duplicates.

License

Notifications You must be signed in to change notification settings

derhuerst/key-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 build status dependency status dev dependency status ISC-licensed chat on gitter

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.