Simple implementation of bi directional map (key
<=> value
) using 2 es6 Map
s in typescript.
npm install bi-directional-map
import { BiDirectionalMap } from 'bi-directional-map/dist';
const map = new BiDirectionalMap<string, string>({ a: 'apple', b: 'banana' });
map.set('o', 'orange');
map.deleteKey('b');
map.deleteValue('apple');
map.size // 1
map.hasKey('a') // false
map.hasValue('banana') // false
Check tests for more examples.