Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/teppeis/multimaps
- Owner: teppeis
- Created: 2018-06-23T14:16:17.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-12-13T21:58:49.000Z (10 days ago)
- Last Synced: 2024-12-16T18:54:56.325Z (7 days ago)
- Topics: javascript, map, typescript
- Language: TypeScript
- Homepage: https://npm.im/@teppeis/multimaps
- Size: 1.8 MB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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