Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/collections/BiMap.ts>default

A JavaScript extension package for building strong and modern applications.
Latest
class default
extends Map<K, V>
import { default } from "https://deno.land/x/ayonli_jsext@v0.9.72/collections/BiMap.ts";

Bi-directional map, keys and values are unique and map to each other.

Examples

Example 1

import { BiMap } from "@ayonli/jsext/collections";

const map = new BiMap<string, string>();

map.set("foo", "hello");
map.set("bar", "world");

console.log(map.get("foo")); // hello
console.log(map.getKey("world")); // bar

map.delete("foo");
console.log(map.hasValue("hello")); // false

map.deleteValue("world");
console.log(map.has("bar")); // false

Constructors

new
default(iterable?: Iterable<readonly [K, V]> | null)

Properties

[inverse]: Map<V, K>
readonly
[Symbol.toStringTag]: "BiMap"

Methods

clear(): void
deleteValue(value: V): boolean
getKey(value: V): K | undefined
hasValue(value: V): boolean
set(key: K, value: V): this