Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | # regjsgen [![Build status][travis-ci-img]][travis-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 in Node.js 0.10, 0.12, 4, 6, 8, 10, 12 and 14.<br>
|
---|
| 34 | Compatible with regjsparser v0.6.4’s AST.
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | [travis-ci]: https://travis-ci.org/bnjmnt4n/regjsgen
|
---|
| 38 | [travis-ci-img]: https://travis-ci.org/bnjmnt4n/regjsgen.svg?branch=master
|
---|
| 39 | [codecov]: https://codecov.io/gh/bnjmnt4n/regjsgen
|
---|
| 40 | [codecov-img]: https://codecov.io/gh/bnjmnt4n/regjsgen/branch/master/graph/badge.svg
|
---|
| 41 | [regjsparser]: https://github.com/jviereck/regjsparser
|
---|
Note:
See
TracBrowser
for help on using the repository browser.