Skip to content

Wrapper around `Map` with utility functions for maps containing an array of items for each key.

License

Notifications You must be signed in to change notification settings

woubuc/multimap

Repository files navigation

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

About

Wrapper around `Map` with utility functions for maps containing an array of items for each key.

Resources

License

Stars

Watchers

Forks

Packages

No packages published