double-indexed-kv.js 514 B

123456789101112131415161718192021
  1. export class DoubleIndexedKV {
  2. constructor() {
  3. this.keyToValue = new Map();
  4. this.valueToKey = new Map();
  5. }
  6. set(key, value) {
  7. this.keyToValue.set(key, value);
  8. this.valueToKey.set(value, key);
  9. }
  10. getByKey(key) {
  11. return this.keyToValue.get(key);
  12. }
  13. getByValue(value) {
  14. return this.valueToKey.get(value);
  15. }
  16. clear() {
  17. this.keyToValue.clear();
  18. this.valueToKey.clear();
  19. }
  20. }
  21. //# sourceMappingURL=double-indexed-kv.js.map