a257b8e1cd4a66baa9b0d70313156e62e862377054d33898aefe203c977f470c2b3d8d322ce01418bb36a1ddd8f7f267622af612644eae41acc364cecc6324 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = getAssignmentIdentifiers;
  6. function getAssignmentIdentifiers(node) {
  7. const search = [].concat(node);
  8. const ids = Object.create(null);
  9. while (search.length) {
  10. const id = search.pop();
  11. if (!id) continue;
  12. switch (id.type) {
  13. case "ArrayPattern":
  14. search.push(...id.elements);
  15. break;
  16. case "AssignmentExpression":
  17. case "AssignmentPattern":
  18. case "ForInStatement":
  19. case "ForOfStatement":
  20. search.push(id.left);
  21. break;
  22. case "ObjectPattern":
  23. search.push(...id.properties);
  24. break;
  25. case "ObjectProperty":
  26. search.push(id.value);
  27. break;
  28. case "RestElement":
  29. case "UpdateExpression":
  30. search.push(id.argument);
  31. break;
  32. case "UnaryExpression":
  33. if (id.operator === "delete") {
  34. search.push(id.argument);
  35. }
  36. break;
  37. case "Identifier":
  38. ids[id.name] = id;
  39. break;
  40. default:
  41. break;
  42. }
  43. }
  44. return ids;
  45. }
  46. //# sourceMappingURL=getAssignmentIdentifiers.js.map