Skip to content

Commit

Permalink
fixing typo
Browse files Browse the repository at this point in the history
root.root to ast.root
  • Loading branch information
alexbit-codemod authored and HerringtonDarkholme committed Apr 18, 2024
1 parent dcae55e commit 27d84ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions website/guide/api-usage/js-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Remember your old time web programming?
A common workflow to use ast-grep's JavaScript API is:

1. Get a syntax tree object `SgRoot` from string by calling a language's `parse` method
2. Get the root node of the syntax tree by calling `root.root()`
2. Get the root node of the syntax tree by calling `ast.root()`
3. `find` relevant nodes by using patterns or rules
4. Collect information from the nodes

Expand Down Expand Up @@ -191,7 +191,7 @@ export class SgNode {

```ts{3}
const ast = js.parse("console.log('hello world')")
root = root.root()
root = ast.root()
root.text() // will return "console.log('hello world')"
```

Expand Down Expand Up @@ -344,4 +344,4 @@ let fileCount = await js.findInFiles({
t.assert(n.length > 0)
t.assert(n[0].text().includes('.'))
})
```
```

0 comments on commit 27d84ac

Please sign in to comment.