Skip to content

Commit daa97d4

Browse files
Remove unused code
1 parent 69b0ee2 commit daa97d4

File tree

1 file changed

+1
-160
lines changed

1 file changed

+1
-160
lines changed

Diff for: index.js

+1-160
Original file line numberDiff line numberDiff line change
@@ -5,163 +5,4 @@
55

66
'use strict';
77

8-
module.exports = require('./dist/regexp-tree');
9-
10-
const compatTranspiler = require('./src/compat-transpiler');
11-
const generator = require('./src/generator');
12-
const optimizer = require('./src/optimizer');
13-
const parser = require('./src/parser');
14-
const transform = require('./src/transform');
15-
const traverse = require('./src/traverse');
16-
const fa = require('./src/interpreter/finite-automaton');
17-
18-
const {RegExpTree} = require('./src/compat-transpiler/runtime');
19-
20-
/**
21-
* An API object for RegExp processing (parsing/transform/generation).
22-
*/
23-
const regexpTree = {
24-
/**
25-
* Parser module exposed.
26-
*/
27-
parser,
28-
29-
/**
30-
* Expose finite-automaton module.
31-
*/
32-
fa,
33-
34-
/**
35-
* `TransformResult` exposed.
36-
*/
37-
TransformResult: transform.TransformResult,
38-
39-
/**
40-
* Parses a regexp string, producing an AST.
41-
*
42-
* @param string regexp
43-
*
44-
* a regular expression in different formats: string, AST, RegExp.
45-
*
46-
* @param Object options
47-
*
48-
* parsing options for this parse call. Default are:
49-
*
50-
* - captureLocations: boolean
51-
* - any other custom options
52-
*
53-
* @return Object AST
54-
*/
55-
parse(regexp, options) {
56-
return parser.parse(`${regexp}`, options);
57-
},
58-
59-
/**
60-
* Traverses a RegExp AST.
61-
*
62-
* @param Object ast
63-
* @param Object | Array<Object> handlers
64-
*
65-
* A `handler` is an object containing handler function for needed
66-
* node types. Example:
67-
*
68-
* regexpTree.traverse(ast, {
69-
* onChar(node) {
70-
* ...
71-
* },
72-
* });
73-
*/
74-
traverse(ast, handlers) {
75-
return traverse.traverse(ast, handlers);
76-
},
77-
78-
/**
79-
* Transforms a regular expression.
80-
*
81-
* A regexp can be passed in different formats (string, regexp or AST),
82-
* applying a set of transformations. It is a convenient wrapper
83-
* on top of "parse-traverse-generate" tool chain.
84-
*
85-
* @param string | AST | RegExp regexp - a regular expression;
86-
* @param Object | Array<Object> handlers - a list of handlers.
87-
*
88-
* @return TransformResult - a transformation result.
89-
*/
90-
transform(regexp, handlers) {
91-
return transform.transform(regexp, handlers);
92-
},
93-
94-
/**
95-
* Generates a RegExp string from an AST.
96-
*
97-
* @param Object ast
98-
*
99-
* Invariant:
100-
*
101-
* regexpTree.generate(regexpTree.parse('/[a-z]+/i')); // '/[a-z]+/i'
102-
*/
103-
generate(ast) {
104-
return generator.generate(ast);
105-
},
106-
107-
/**
108-
* Creates a RegExp object from a regexp string.
109-
*
110-
* @param string regexp
111-
*/
112-
toRegExp(regexp) {
113-
const compat = this.compatTranspile(regexp);
114-
return new RegExp(compat.getSource(), compat.getFlags());
115-
},
116-
117-
/**
118-
* Optimizes a regular expression by replacing some
119-
* sub-expressions with their idiomatic patterns.
120-
*
121-
* @param string regexp
122-
*
123-
* @return TransformResult object
124-
*/
125-
optimize(regexp, whitelist) {
126-
return optimizer.optimize(regexp, whitelist);
127-
},
128-
129-
/**
130-
* Translates a regular expression in new syntax or in new format
131-
* into equivalent expressions in old syntax.
132-
*
133-
* @param string regexp
134-
*
135-
* @return TransformResult object
136-
*/
137-
compatTranspile(regexp, whitelist) {
138-
return compatTranspiler.transform(regexp, whitelist);
139-
},
140-
141-
/**
142-
* Executes a regular expression on a string.
143-
*
144-
* @param RegExp|string re - a regular expression.
145-
* @param string string - a testing string.
146-
*/
147-
exec(re, string) {
148-
if (typeof re === 'string') {
149-
const compat = this.compatTranspile(re);
150-
const extra = compat.getExtra();
151-
152-
if (extra.namedCapturingGroups) {
153-
re = new RegExpTree(compat.toRegExp(), {
154-
flags: compat.getFlags(),
155-
source: compat.getSource(),
156-
groups: extra.namedCapturingGroups,
157-
});
158-
} else {
159-
re = compat.toRegExp();
160-
}
161-
}
162-
163-
return re.exec(string);
164-
},
165-
};
166-
167-
module.exports = regexpTree;
8+
module.exports = require('./dist/regexp-tree');

0 commit comments

Comments
 (0)