cache.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.clear = clear;
  6. exports.clearPath = clearPath;
  7. exports.clearScope = clearScope;
  8. exports.getCachedPaths = getCachedPaths;
  9. exports.getOrCreateCachedPaths = getOrCreateCachedPaths;
  10. exports.scope = exports.path = void 0;
  11. let pathsCache = exports.path = new WeakMap();
  12. let scope = exports.scope = new WeakMap();
  13. function clear() {
  14. clearPath();
  15. clearScope();
  16. }
  17. function clearPath() {
  18. exports.path = pathsCache = new WeakMap();
  19. }
  20. function clearScope() {
  21. exports.scope = scope = new WeakMap();
  22. }
  23. const nullHub = Object.freeze({});
  24. function getCachedPaths(hub, parent) {
  25. var _pathsCache$get, _hub;
  26. {
  27. hub = null;
  28. }
  29. return (_pathsCache$get = pathsCache.get((_hub = hub) != null ? _hub : nullHub)) == null ? void 0 : _pathsCache$get.get(parent);
  30. }
  31. function getOrCreateCachedPaths(hub, parent) {
  32. var _hub2, _hub3;
  33. {
  34. hub = null;
  35. }
  36. let parents = pathsCache.get((_hub2 = hub) != null ? _hub2 : nullHub);
  37. if (!parents) pathsCache.set((_hub3 = hub) != null ? _hub3 : nullHub, parents = new WeakMap());
  38. let paths = parents.get(parent);
  39. if (!paths) parents.set(parent, paths = new Map());
  40. return paths;
  41. }
  42. //# sourceMappingURL=cache.js.map