Skip to content

Commit 876a59a

Browse files
committed
Docs: update README.md
1 parent 004aa0d commit 876a59a

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The regular expression parser for ECMAScript.
1414
$ npm install regexpp
1515
```
1616

17-
- require Node.js 4.0.0 or newer.
17+
- require Node.js 6.5.0 or newer.
1818

1919
## 📖 Usage
2020

@@ -23,8 +23,10 @@ import {
2323
AST,
2424
RegExpParser,
2525
RegExpValidator,
26+
RegExpVisitor,
2627
parseRegExpLiteral,
2728
validateRegExpLiteral,
29+
visitRegExpAST
2830
} from "regexpp"
2931
```
3032

@@ -50,6 +52,16 @@ This is equivalent to `new RegExpValidator(options).validateLiteral(source)`.
5052
- `source` (`string`) The source code to validate.
5153
- `options?` ([`RegExpValidator.Options`]) The options to validate.
5254

55+
### visitRegExpAST(ast, handlers)
56+
57+
Visit each node of a given AST.
58+
59+
This is equivalent to `new RegExpVisitor(handlers).visit(ast)`.
60+
61+
- **Parameters:**
62+
- `ast` ([`AST.Node`]) The AST to visit.
63+
- `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
64+
5365
### RegExpParser
5466

5567
#### new RegExpParser(options?)
@@ -126,6 +138,20 @@ Validate a regular expression flags.
126138
- `start?` (`number`) The start index in the source code. Default is `0`.
127139
- `end?` (`number`) The end index in the source code. Default is `source.length`.
128140

141+
### RegExpVisitor
142+
143+
#### new RegExpVisitor(handlers)
144+
145+
- **Parameters:**
146+
- `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
147+
148+
#### visitor.visit(ast)
149+
150+
Validate a regular expression literal.
151+
152+
- **Parameters:**
153+
- `ast` ([`AST.Node`]) The AST to visit.
154+
129155
## 📰 Changelog
130156

131157
- [GitHub Releases](https://github.com/mysticatea/regexpp/releases)
@@ -146,5 +172,7 @@ Please use GitHub's Issues/PRs.
146172
- `npm run update:ids` updates `src/unicode/ids.ts`.
147173
- `npm run watch` runs tests with `--watch` option.
148174

149-
[`RegExpParser.Options`]: src/parser.ts#L527
175+
[`AST.Node`]: src/ast.ts#L4
176+
[`RegExpParser.Options`]: src/parser.ts#L539
150177
[`RegExpValidator.Options`]: src/validator.ts#L127
178+
[`RegExpVisitor.Handlers`]: src/visitor.ts#L204

0 commit comments

Comments
 (0)