Skip to content

Instantly share code, notes, and snippets.

View ViaRationis's full-sized avatar
⁉️

Linx ViaRationis

⁉️
  • The Digital Empire
  • Digital World
View GitHub Profile
@ViaRationis
ViaRationis / bidirectional-map.js
Last active November 15, 2023 07:12
Bidirectional Map. Unique-valued map where you can look up keys by value.
// bidirectional-map.js
// BidirectionalMap, StrictBidirectionalMap, SilentBidirectionalMap
// Two-way map. Same API as Map with the addition of getKey, hasValue, and deleteValue.
// In this version, values will stay unique by deleting previous keys.
export class BidirectionalMap extends Map {
#inverseMap = new Map();
constructor(entries) {