项目原始demo,不改动
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
Questo repository è archiviato. Puoi vedere i file e clonarli, ma non puoi effettuare richieste di pushj o aprire problemi/richieste di pull.

123456789101112131415161718192021222324252627282930313233
  1. # babel-traverse
  2. > babel-traverse maintains the overall tree state, and is responsible for replacing, removing, and adding nodes.
  3. ## Install
  4. ```sh
  5. $ npm install --save babel-traverse
  6. ```
  7. ## Usage
  8. We can use it alongside Babylon to traverse and update nodes:
  9. ```js
  10. import * as babylon from "babylon";
  11. import traverse from "babel-traverse";
  12. const code = `function square(n) {
  13. return n * n;
  14. }`;
  15. const ast = babylon.parse(code);
  16. traverse(ast, {
  17. enter(path) {
  18. if (path.isIdentifier({ name: "n" })) {
  19. path.node.name = "x";
  20. }
  21. }
  22. });
  23. ```
  24. [:book: **Read the full docs here**](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-traverse)