Multikey Map
A simple map implementation that supports multiple keys, using ES6 Map
and WeakMap
internally.
Installation
yarn add multikey-map
npm install multikey-map --save
Usage
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]);
map.get(['foo', 1]);
map.get(['foo', 2]);
map.has(['foo', 2]);
map.hasAndGet(['foo', 2]);
map.set(['bar', 0], undefined);
map.get(['bar', 0]);
map.has(['bar', 0]);
map.hasAndGet(['bar', 0]);
let weakMap = new MultikeyMap<[object, object], number | undefined>(true);
License
MIT License.