https://github.com/vilicvane/multikey-map
https://github.com/vilicvane/multikey-map
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vilicvane/multikey-map
- Owner: vilicvane
- License: mit
- Created: 2017-08-21T09:15:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-18T10:30:03.000Z (almost 2 years ago)
- Last Synced: 2025-07-25T03:07:41.854Z (4 months ago)
- Language: TypeScript
- Size: 261 KB
- Stars: 2
- Watchers: 1
- 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.