Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 809 Bytes

README.md

File metadata and controls

32 lines (24 loc) · 809 Bytes

MultiMap

npm

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/multimap

Use 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)

View the full API docs

License

MIT license