1 |
3a515b92
|
cagy
|
# RegJSGen
|
2 |
|
|
|
3 |
|
|
Generate `RegExp`s from [RegJSParser](https://github.com/jviereck/regjsparser)’s AST.
|
4 |
|
|
|
5 |
|
|
## Installation
|
6 |
|
|
|
7 |
|
|
```bash
|
8 |
|
|
npm install --save regjsgen
|
9 |
|
|
```
|
10 |
|
|
|
11 |
|
|
## Usage
|
12 |
|
|
|
13 |
|
|
```js
|
14 |
|
|
var regjsgen = require('regjsgen');
|
15 |
|
|
// With `regjsparser`
|
16 |
|
|
var regjsparser = require('regjsparser');
|
17 |
|
|
var regex = '^a$';
|
18 |
|
|
var ast = regjsparser.parse(regex);
|
19 |
|
|
// Modify AST
|
20 |
|
|
// ...
|
21 |
|
|
// Regenerate `RegExp`
|
22 |
|
|
regex = regjsgen.generate(ast);
|
23 |
|
|
```
|
24 |
|
|
|
25 |
|
|
## See Also
|
26 |
|
|
|
27 |
|
|
* [RegJSParser](https://github.com/jviereck/regjsparser)
|
28 |
|
|
* [RegExp.js](https://github.com/jviereck/regexp.js)
|
29 |
|
|
|
30 |
|
|
## Testing
|
31 |
|
|
|
32 |
|
|
Run the command
|
33 |
|
|
|
34 |
|
|
```bash
|
35 |
|
|
npm test
|
36 |
|
|
```
|
37 |
|
|
|
38 |
|
|
To create a new reference file, execute
|
39 |
|
|
|
40 |
|
|
```bash
|
41 |
|
|
node test/update-fixture.js
|
42 |
|
|
```
|
43 |
|
|
|
44 |
|
|
from the repo top directory.
|
45 |
|
|
|
46 |
|
|
## Support
|
47 |
|
|
|
48 |
|
|
Tested in Node.js 0.8.26~0.10.30.
|
49 |
|
|
|
50 |
|
|
## Author
|
51 |
|
|
|
52 |
|
|
| [](https://twitter.com/demoneaux "Follow @demoneaux on Twitter") |
|
53 |
|
|
|---|
|
54 |
|
|
| [Benjamin Tan](http://d10.github.io/) |
|
55 |
|
|
|
56 |
|
|
## Contributors
|
57 |
|
|
|
58 |
|
|
| [](https://twitter.com/mathias "Follow @mathias on Twitter") |
|
59 |
|
|
|---|
|
60 |
|
|
| [Mathias Bynens](http://mathiasbynens.be/) |
|