@vates/multi-key-map

0.2.0 • Public • Published

@vates/multi-key-map

Package Version License PackagePhobia Node compatibility

Create map with values affected to multiple keys

Install

Installation of the npm package:

npm install --save @vates/multi-key-map

Usage

import { MultiKeyMap } from '@vates/multi-key-map'

const map = new MultiKeyMap()

const OBJ = {}
map.set([], 0)
map.set(['foo'], 1)
map.set(['foo', 'bar'], 2)
map.set(['bar', 'foo'], 3)
map.set([OBJ], 4)
map.set([{}], 5)

map.get([]) // 0
map.get(['foo']) // 1
map.get(['foo', 'bar']) // 2
map.get(['bar', 'foo']) // 3
map.get([OBJ]) // 4
map.get([{}]) // undefined

map.delete([])

for (const [key, value] of map.entries() {
  console.log(key, value)
}

for (const  value of map.values()) {
  console.log(value)
}

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Vates SAS

Readme

Keywords

Package Sidebar

Install

npm i @vates/multi-key-map

Weekly Downloads

7

Version

0.2.0

License

ISC

Unpacked Size

4.93 kB

Total Files

3

Last publish

Collaborators

  • stephane-m-dev
  • mlssfrncjrg
  • b-nollet
  • arnogues
  • florent.beauchamp
  • mathieura
  • enishowk
  • tgoettelmann
  • julien-f
  • marsaud
  • olivierlambert
  • pdonias