@woubuc/multimap
v2.1.0
Published
Wrapper around Map with utility functions for maps containing an array of items for each key.
Maintainers
Readme
MultiMap
Wrappers around Map with utility functions for maps containing arrays or sets of items for each key.
Usage
Install the package into your dependencies
pnpm add @woubuc/multimapUse the map
import { ArrayMap, SetMap } from '@woubuc/multimap';
let arrays = new ArrayMap();
arrays.set('foo', [1]); // foo: [1]
arrays.push('foo', 2); // foo: [1, 2]
arrays.delete('foo'); // foo: undefined
arrays.push('foo', 3); // foo: [3]
let sets = new SetMap();
sets.add('foo', 1); // foo: Set(1)
sets.add('foo', 1); // foo: Set(1)
sets.add('foo', 2); // foo: Set(1, 2)