@@ -34,26 +34,26 @@ function compileSingle(elements: RegexElement): string {
34
34
return elements ;
35
35
}
36
36
37
- if ( 'children' in elements ) {
38
- const compiledChildren = compileList ( elements . children ) ;
37
+ if ( ! ( 'children' in elements ) ) {
38
+ const characterCompiler = characterClasses [ elements . type ] ;
39
39
40
- if ( elements . type === 'repeat' ) {
41
- return compileRepeat ( elements . config , compiledChildren ) ;
40
+ if ( ! characterCompiler ) {
41
+ throw new Error ( `Unknown character type ${ elements . type } ` ) ;
42
42
}
43
43
44
- const elementCompiler = quantifiers [ elements . type ] ;
45
- if ( ! elementCompiler ) {
46
- throw new Error ( `Unknown elements type ${ elements . type } ` ) ;
47
- }
48
-
49
- return elementCompiler ( compiledChildren ) ;
44
+ return characterCompiler ;
50
45
}
51
46
52
- const characterCompiler = characterClasses [ elements . type ] ;
47
+ const compiledChildren = compileList ( elements . children ) ;
48
+
49
+ if ( elements . type === 'repeat' ) {
50
+ return compileRepeat ( elements . config , compiledChildren ) ;
51
+ }
53
52
54
- if ( ! characterCompiler ) {
55
- throw new Error ( `Unknown character type ${ elements . type } ` ) ;
53
+ const elementCompiler = quantifiers [ elements . type ] ;
54
+ if ( ! elementCompiler ) {
55
+ throw new Error ( `Unknown elements type ${ elements . type } ` ) ;
56
56
}
57
57
58
- return characterCompiler ;
58
+ return elementCompiler ( compiledChildren ) ;
59
59
}
0 commit comments