项目原始demo,不改动
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
このリポジトリはアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュや、課題・プルリクエストのオープンはできません。

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)