reference.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  3. if (k2 === undefined) k2 = k;
  4. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  5. }) : (function(o, m, k, k2) {
  6. if (k2 === undefined) k2 = k;
  7. o[k2] = m[k];
  8. }));
  9. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  10. Object.defineProperty(o, "default", { enumerable: true, value: v });
  11. }) : function(o, v) {
  12. o["default"] = v;
  13. });
  14. var __importStar = (this && this.__importStar) || function (mod) {
  15. if (mod && mod.__esModule) return mod;
  16. var result = {};
  17. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  18. __setModuleDefault(result, mod);
  19. return result;
  20. };
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. const t = __importStar(require("@babel/types"));
  23. function isReferenced(node, parent) {
  24. switch (parent.type) {
  25. // yes: { [NODE]: '' }
  26. // yes: { NODE }
  27. // no: { NODE: '' }
  28. case 'ObjectProperty':
  29. return parent.value === node || parent.computed;
  30. // no: break NODE;
  31. // no: continue NODE;
  32. case 'BreakStatement':
  33. case 'ContinueStatement':
  34. return false;
  35. // yes: left = NODE;
  36. // yes: NODE = right;
  37. case 'AssignmentExpression':
  38. return true;
  39. }
  40. return t.isReferenced(node, parent);
  41. }
  42. exports.default = isReferenced;
  43. //# sourceMappingURL=reference.js.map