cache.js 899 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. function getCachedPaths(path) {
  24. const {
  25. parent,
  26. parentPath
  27. } = path;
  28. return pathsCache.get(parent);
  29. }
  30. function getOrCreateCachedPaths(node, parentPath) {
  31. ;
  32. let paths = pathsCache.get(node);
  33. if (!paths) pathsCache.set(node, paths = new Map());
  34. return paths;
  35. }
  36. //# sourceMappingURL=cache.js.map