TwoWayMap<Key, Value>
A map that allows you to look up a value by its key and vice versa.
Import:
import { TwoWayMap } from 'obsidian-dev-utils/two-way-map';Example:
const map = new TwoWayMap<string, number>();map.set('foo', 42);map.getValue('foo'); // 42map.getKey(42); // 'foo'map.deleteKey('foo');map.deleteValue(42);map.clear();Signature:
export class TwoWayMap<Key, Value>Constructor
new TwoWayMap(entries?: (readonly [key: Key, value: Value])[])Creates a new two-way map.
Methods
| Method | Returns | Description |
|---|---|---|
| clear() | void | Clears the map. |
| deleteKey(key) | void | Deletes a key from the map. |
| deleteValue(value) | void | Deletes a value from the map. |
| entries() | IterableIterator<readonly [key: Key, value: Value]> | Gets all entries in the map. |
| getKey(value) | Key | undefined | Gets a key by its value. |
| getValue(key) | undefined | Value | Gets a value by its key. |
| hasKey(key) | boolean | Checks if the map has a key. |
| hasValue(value) | boolean | Checks if the map has a value. |
| keys() | IterableIterator<Key> | Gets all keys in the map. |
| set(key, value) | void | Sets a key-value pair in the map. |
| values() | IterableIterator<Value> | Gets all values in the map. |
Links to this page: