main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | # regjsgen [![Build status][ci-img]][ci] [![Code coverage status][codecov-img]][codecov]
|
---|
2 |
|
---|
3 | Generate regular expressions from [regjsparser][regjsparser]’s AST.
|
---|
4 |
|
---|
5 | ## Installation
|
---|
6 |
|
---|
7 | ```sh
|
---|
8 | npm i regjsgen
|
---|
9 | ```
|
---|
10 |
|
---|
11 | ## API
|
---|
12 |
|
---|
13 | ### `regjsgen.generate(ast)`
|
---|
14 |
|
---|
15 | This function accepts an abstract syntax tree representing a regular expression (see [regjsparser][regjsparser]), and returns the generated regular expression string.
|
---|
16 |
|
---|
17 | ```js
|
---|
18 | const regjsparser = require('regjsparser');
|
---|
19 | const regjsgen = require('regjsgen');
|
---|
20 |
|
---|
21 | // Generate an AST with `regjsparser`.
|
---|
22 | let ast = regjsparser.parse(regex);
|
---|
23 |
|
---|
24 | // Modify AST
|
---|
25 | // …
|
---|
26 |
|
---|
27 | // Generate `RegExp` string with `regjsgen`.
|
---|
28 | let regex = regjsgen.generate(ast);
|
---|
29 | ```
|
---|
30 |
|
---|
31 | ## Support
|
---|
32 |
|
---|
33 | Tested on Node.js 16 and 18.<br>
|
---|
34 | Compatible with regjsparser v0.10.0’s AST.
|
---|
35 |
|
---|
36 |
|
---|
37 | [ci]: https://github.com/bnjmnt4n/regjsgen/actions
|
---|
38 | [ci-img]: https://github.com/bnjmnt4n/regjsgen/workflows/Node.js%20CI/badge.svg
|
---|
39 | [codecov]: https://codecov.io/gh/bnjmnt4n/regjsgen
|
---|
40 | [codecov-img]: https://codecov.io/gh/bnjmnt4n/regjsgen/branch/main/graph/badge.svg
|
---|
41 | [regjsparser]: https://github.com/jviereck/regjsparser
|
---|
Note:
See
TracBrowser
for help on using the repository browser.