https://github.com/vilicvane/multikey-map
https://github.com/vilicvane/multikey-map
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vilicvane/multikey-map
- Owner: vilicvane
- License: mit
- Created: 2017-08-21T09:15:01.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-18T10:30:03.000Z (over 1 year ago)
- Last Synced: 2024-11-24T22:32:55.724Z (8 months ago)
- Language: TypeScript
- Size: 261 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/multikey-map)
[](./package.json)
[](./LICENSE)
[](https://discord.gg/wEVn2qcf8h)# Multikey Map
A simple map implementation that supports multiple keys.
> `multikey-map` uses `mixed-map` internally, which is a map implementation that uses both `Map` and `WeakMap` internally.
## Installation
```sh
npm install multikey-map
```## Usage
```ts
import MultikeyMap from 'multikey-map';let map = new MultikeyMap<[string, number], string | undefined>();
map.set(['foo', 0], 'a');
map.set(['foo', 1], 'b');map.get(['foo', 0]); // 'a'
map.get(['foo', 1]); // 'b'
map.get(['foo', 2]); // undefined
map.has(['foo', 2]); // false
map.hasAndGet(['foo', 2]); // [false, undefined]map.set(['bar', 0], undefined);
map.get(['bar', 0]); // undefined
map.has(['bar', 0]); // true
map.hasAndGet(['bar', 0]); // [true, undefined]
```## License
MIT License.