key-map

1.0.0 • Public • Published

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.

Package Sidebar

Install

npm i key-map

Weekly Downloads

3

Version

1.0.0

License

ISC

Last publish

Collaborators

  • derhuerst