JSPM

@a11d/bidirectional-map

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 511
  • Score
    100M100P100Q109054F
  • License MIT

Map with bidirectional lookups - query by key or value

Package Exports

  • @a11d/bidirectional-map
  • @a11d/bidirectional-map/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@a11d/bidirectional-map) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@a11d/bidirectional-map

A Map implementation that maintains a bidirectional relationship between keys and values, allowing lookups in both directions.

import '@a11d/bidirectional-map'

const map = new BidirectionalMap([
    ['en', 'English'],
    ['fr', 'French'],
])

map.get('en') // 'English'
map.getKey('English') // 'en'

Installation

npm install @a11d/bidirectional-map

API

Implements the standard Map<K, V> interface with additional methods:

getKey(value: V): K | undefined — Get key by value (reverse lookup)
const map = new BidirectionalMap([['en', 'English'], ['fr', 'French']])
map.getKey('English') // 'en'
map.getKey('Spanish') // undefined
hasValue(value: V): boolean — Check if a value exists
const map = new BidirectionalMap([['en', 'English']])
map.hasValue('English') // true
map.hasValue('French') // false
deleteValue(value: V): boolean — Remove entry by value
const map = new BidirectionalMap([['en', 'English']])
map.deleteValue('English') // true
map.has('en') // false

Global Type

The package automatically registers itself globally, so TypeScript recognizes BidirectionalMap without explicit imports:

// Type is available globally
const map: BidirectionalMap<string, number> = new BidirectionalMap()