Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/teppeis/multimaps

Multimap classes for TypeScript and JavaScript
https://github.com/teppeis/multimaps

javascript map typescript

Last synced: 3 days ago
JSON representation

Multimap classes for TypeScript and JavaScript

Awesome Lists containing this project

README

        

# @teppeis/multimaps

Multi-Map classes for TypeScript and JavaScript

[![npm version][npm-image]][npm-url]
![Node.js Version Support][node-version]
![TypeScript Version Support][ts-version]
[![build status][ci-image]][ci-url]
![monthly downloads][npm-downloads-image]
![License][license]

## Install

```console
$ npm i @teppeis/multimaps
```

## Usage

### `ArrayMultimap`

```js
import {ArrayMultimap} from '@teppeis/multimaps';

const map = new ArrayMultimap();
map.put('foo', 'a');
map.get('foo'); // ['a']
map.put('foo', 'b');
map.get('foo'); // ['a', 'b']
map.put('foo', 'a');
map.get('foo'); // ['a', 'b', 'a']
```

### `SetMultimap`

```js
import {SetMultimap} from '@teppeis/multimaps';

const map = new SetMultimap();
map.put('foo', 'a');
map.get('foo'); // a `Set` of ['a']
map.put('foo', 'b');
map.get('foo'); // a `Set` of ['a', 'b']
map.put('foo', 'a');
map.get('foo'); // a `Set` of ['a', 'b']
```

## License

MIT License: Teppei Sato <[email protected]>

[npm-image]: https://badgen.net/npm/v/@teppeis/multimaps?icon=npm&label=
[npm-url]: https://npmjs.org/package/@teppeis/multimaps
[npm-downloads-image]: https://badgen.net/npm/dm/@teppeis/multimaps
[node-version]: https://badgen.net/npm/node/@teppeis/multimaps
[ts-version]: https://badgen.net/badge/typescript/%3E=4.6?icon=typescript
[license]: https://img.shields.io/npm/l/@teppeis/multimaps.svg
[ci-image]: https://github.com/teppeis/multimaps/workflows/CI/badge.svg
[ci-url]: https://github.com/teppeis/multimaps/actions?query=workflow%3ACI