Skip to content

Commit

Permalink
Adding documentation and information (#5717) [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanbayatme authored and hzoo committed Jun 9, 2017
1 parent dd82d7a commit 1b29ab1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/babel-traverse/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# babel-traverse

> babel-traverse maintains the overall tree state, and is responsible for replacing, removing, and adding nodes.
## Install

```sh
$ npm install --save babel-traverse
```

## Usage

We can use it alongside Babylon to traverse and update nodes:

```js
import * as babylon from "babylon";
import traverse from "babel-traverse";

const code = `function square(n) {
return n * n;
}`;

const ast = babylon.parse(code);

traverse(ast, {
enter(path) {
if (path.isIdentifier({ name: "n" })) {
path.node.name = "x";
}
}
});
```
[:book: **Read the full docs here**](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-traverse)

0 comments on commit 1b29ab1

Please sign in to comment.