# babel-traverse

> The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes

Latest version **6.26.0** (published 2017-08-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-traverse
pnpm add babel-traverse
yarn add babel-traverse
bun add babel-traverse
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; high maintenance score; popular repo.

Warnings: low downloads; no esm support; has vulnerabilities.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 6.26.0 |
| Published | 2017-08-16 |
| First published | 2015-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/babel-traverse) |
| Module format | CommonJS |
| Dependencies | 9 |
| Known vulnerabilities | 1 |
| Install scripts | no |
| GitHub stars | 43992 |
| Author | Sebastian McKenzie |
| Maintainers | thejameskyle, sebmck, danez, hzoo, loganfsmyth |

## Links

- npm: https://www.npmjs.com/package/babel-traverse
- Repository: https://github.com/babel/babel/tree/master/packages/babel-traverse
- Homepage: https://babeljs.io/
- npm.io page: https://npm.io/package/babel-traverse

## Dependencies (9)

- [debug](https://npm.io/package/debug.md) ^2.6.8
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [babylon](https://npm.io/package/babylon.md) ^6.18.0
- [globals](https://npm.io/package/globals.md) ^9.18.0
- [invariant](https://npm.io/package/invariant.md) ^2.2.2
- [babel-types](https://npm.io/package/babel-types.md) ^6.26.0
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.26.0
- [babel-messages](https://npm.io/package/babel-messages.md) ^6.23.0
- [babel-code-frame](https://npm.io/package/babel-code-frame.md) ^6.26.0

## Recent versions

- 6.26.0 (latest) — 2017-08-16
- 7.0.0-beta.3 (next) — 2017-10-15
- 7.0.0-beta.2 — 2017-09-26
- 7.0.0-beta.1 — 2017-09-19
- 7.0.0-beta.0 — 2017-09-12
- 7.0.0-alpha.20 — 2017-08-30
- 7.0.0-alpha.19 — 2017-08-07
- 7.0.0-alpha.18 — 2017-08-03
- 7.0.0-alpha.17 — 2017-07-26
- 7.0.0-alpha.16 — 2017-07-25
- 7.0.0-alpha.15 — 2017-07-12
- 7.0.0-alpha.14 — 2017-07-12
- 6.25.0 — 2017-06-08
- 7.0.0-alpha.12 — 2017-05-31
- 7.0.0-alpha.11 — 2017-05-31
- … 63 more at https://npm.io/package/babel-traverse/versions

## README

# 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)

---
_Source: https://npm.io/package/babel-traverse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
