提交学习笔记专用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
860 B

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Registry = void 0;
  4. const double_indexed_kv_js_1 = require("./double-indexed-kv.cjs");
  5. class Registry {
  6. constructor(generateIdentifier) {
  7. this.generateIdentifier = generateIdentifier;
  8. this.kv = new double_indexed_kv_js_1.DoubleIndexedKV();
  9. }
  10. register(value, identifier) {
  11. if (this.kv.getByValue(value)) {
  12. return;
  13. }
  14. if (!identifier) {
  15. identifier = this.generateIdentifier(value);
  16. }
  17. this.kv.set(identifier, value);
  18. }
  19. clear() {
  20. this.kv.clear();
  21. }
  22. getIdentifier(value) {
  23. return this.kv.getByValue(value);
  24. }
  25. getValue(identifier) {
  26. return this.kv.getByKey(identifier);
  27. }
  28. }
  29. exports.Registry = Registry;
  30. //# sourceMappingURL=registry.js.map