Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liammartens/dynamic-multikey-map
https://github.com/liammartens/dynamic-multikey-map
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/liammartens/dynamic-multikey-map
- Owner: LiamMartens
- License: mit
- Created: 2024-02-07T14:18:23.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-07T14:26:31.000Z (11 months ago)
- Last Synced: 2024-10-18T16:14:23.531Z (2 months ago)
- Language: TypeScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dynamic-multikey-map
[![badge](https://img.shields.io/npm/v/dynamic-multikey-map)](https://www.npmjs.com/package/dynamic-multikey-map) [![badge](https://img.shields.io/bundlephobia/min/dynamic-multikey-map)](https://bundlephobia.com/package/dynamic-multikey-map) ![badge](https://img.shields.io/github/license/LiamMartens/dynamic-multikey-map)
This is a dynamic multiple key map to map a single object to multiple dynamic values.
## Usage
```js
import { MultiKeyMap } from "dynamic-multikey-map";type ValueType = {
username: string;
ssn: string;
};const map = new MultiKeyMap([
(value: ValueType) => value.ssn,
(value: ValueType) => value.username,
]);map.add({
username: "john.doe",
ssn: "123-45-6789",
});expect(map.get("john.doe")).toEqual(map.get("123-45-6789"));
```