@renovatebot/good-enough-parser 1.1.24 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +6 -6
  2. package/dist/cjs/index.d.ts +4 -4
  3. package/dist/cjs/index.js +7 -7
  4. package/dist/cjs/lang/groovy.d.ts +6 -6
  5. package/dist/cjs/lang/groovy.js +83 -83
  6. package/dist/cjs/lang/index.d.ts +20 -20
  7. package/dist/cjs/lang/index.js +56 -56
  8. package/dist/cjs/lang/python.d.ts +6 -6
  9. package/dist/cjs/lang/python.js +73 -73
  10. package/dist/cjs/lang/scala.d.ts +6 -6
  11. package/dist/cjs/lang/scala.js +71 -71
  12. package/dist/cjs/lang/starlark.d.ts +6 -6
  13. package/dist/cjs/lang/starlark.js +58 -58
  14. package/dist/cjs/lang/types.d.ts +6 -6
  15. package/dist/cjs/lang/types.js +2 -2
  16. package/dist/cjs/lexer/bracket.d.ts +6 -6
  17. package/dist/cjs/lexer/bracket.js +57 -57
  18. package/dist/cjs/lexer/comment.d.ts +3 -3
  19. package/dist/cjs/lexer/comment.js +44 -44
  20. package/dist/cjs/lexer/index.d.ts +5 -5
  21. package/dist/cjs/lexer/index.js +155 -155
  22. package/dist/cjs/lexer/number.d.ts +2 -2
  23. package/dist/cjs/lexer/number.js +18 -18
  24. package/dist/cjs/lexer/operator.d.ts +2 -2
  25. package/dist/cjs/lexer/operator.js +24 -24
  26. package/dist/cjs/lexer/rules.d.ts +4 -4
  27. package/dist/cjs/lexer/rules.js +74 -74
  28. package/dist/cjs/lexer/string.d.ts +2 -2
  29. package/dist/cjs/lexer/string.js +181 -181
  30. package/dist/cjs/lexer/symbol.d.ts +2 -2
  31. package/dist/cjs/lexer/symbol.js +18 -18
  32. package/dist/cjs/lexer/token.d.ts +3 -3
  33. package/dist/cjs/lexer/token.js +64 -64
  34. package/dist/cjs/lexer/types.d.ts +142 -142
  35. package/dist/cjs/lexer/types.js +2 -2
  36. package/dist/cjs/parser/cursor.d.ts +2 -2
  37. package/dist/cjs/parser/cursor.js +13 -13
  38. package/dist/cjs/parser/index.d.ts +3 -3
  39. package/dist/cjs/parser/index.js +19 -19
  40. package/dist/cjs/parser/tree.d.ts +4 -4
  41. package/dist/cjs/parser/tree.js +246 -246
  42. package/dist/cjs/parser/types.d.ts +33 -33
  43. package/dist/cjs/parser/types.js +2 -2
  44. package/dist/cjs/query/builder.d.ts +144 -144
  45. package/dist/cjs/query/builder.js +332 -332
  46. package/dist/cjs/query/handler.d.ts +2 -2
  47. package/dist/cjs/query/handler.js +10 -10
  48. package/dist/cjs/query/index.d.ts +2 -2
  49. package/dist/cjs/query/index.js +32 -32
  50. package/dist/cjs/query/matchers/abstract-matcher.d.ts +9 -9
  51. package/dist/cjs/query/matchers/abstract-matcher.js +36 -36
  52. package/dist/cjs/query/matchers/alt-matcher.d.ts +10 -10
  53. package/dist/cjs/query/matchers/alt-matcher.js +33 -33
  54. package/dist/cjs/query/matchers/anchor-matcher.d.ts +17 -17
  55. package/dist/cjs/query/matchers/anchor-matcher.js +50 -50
  56. package/dist/cjs/query/matchers/comment-matcher.d.ts +10 -10
  57. package/dist/cjs/query/matchers/comment-matcher.js +39 -39
  58. package/dist/cjs/query/matchers/index.d.ts +6 -6
  59. package/dist/cjs/query/matchers/index.js +22 -22
  60. package/dist/cjs/query/matchers/many-matcher.d.ts +13 -13
  61. package/dist/cjs/query/matchers/many-matcher.js +61 -61
  62. package/dist/cjs/query/matchers/num-matcher.d.ts +8 -8
  63. package/dist/cjs/query/matchers/num-matcher.js +34 -34
  64. package/dist/cjs/query/matchers/op-matcher.d.ts +8 -8
  65. package/dist/cjs/query/matchers/op-matcher.js +34 -34
  66. package/dist/cjs/query/matchers/seq-matcher.d.ts +14 -14
  67. package/dist/cjs/query/matchers/seq-matcher.js +76 -76
  68. package/dist/cjs/query/matchers/str-matcher.d.ts +38 -38
  69. package/dist/cjs/query/matchers/str-matcher.js +108 -108
  70. package/dist/cjs/query/matchers/sym-matcher.d.ts +8 -8
  71. package/dist/cjs/query/matchers/sym-matcher.js +34 -34
  72. package/dist/cjs/query/matchers/tree-matcher.d.ts +23 -23
  73. package/dist/cjs/query/matchers/tree-matcher.js +121 -121
  74. package/dist/cjs/query/options.d.ts +10 -10
  75. package/dist/cjs/query/options.js +149 -149
  76. package/dist/cjs/query/regex.d.ts +1 -1
  77. package/dist/cjs/query/regex.js +13 -13
  78. package/dist/cjs/query/types.d.ts +100 -100
  79. package/dist/cjs/query/types.js +2 -2
  80. package/dist/cjs/util/clone.d.ts +1 -1
  81. package/dist/cjs/util/clone.js +5 -5
  82. package/dist/cjs/util/regex.d.ts +1 -1
  83. package/dist/cjs/util/regex.js +7 -7
  84. package/dist/esm/index.d.ts +4 -4
  85. package/dist/esm/index.js +8 -8
  86. package/dist/esm/lang/groovy.d.ts +6 -6
  87. package/dist/esm/lang/groovy.js +80 -80
  88. package/dist/esm/lang/index.d.ts +20 -20
  89. package/dist/esm/lang/index.js +37 -37
  90. package/dist/esm/lang/python.d.ts +6 -6
  91. package/dist/esm/lang/python.js +70 -70
  92. package/dist/esm/lang/scala.d.ts +6 -6
  93. package/dist/esm/lang/scala.js +68 -68
  94. package/dist/esm/lang/starlark.d.ts +6 -6
  95. package/dist/esm/lang/starlark.js +55 -55
  96. package/dist/esm/lang/types.d.ts +6 -6
  97. package/dist/esm/lang/types.js +1 -1
  98. package/dist/esm/lexer/bracket.d.ts +6 -6
  99. package/dist/esm/lexer/bracket.js +49 -49
  100. package/dist/esm/lexer/comment.d.ts +3 -3
  101. package/dist/esm/lexer/comment.js +39 -39
  102. package/dist/esm/lexer/index.d.ts +5 -5
  103. package/dist/esm/lexer/index.js +136 -136
  104. package/dist/esm/lexer/number.d.ts +2 -2
  105. package/dist/esm/lexer/number.js +14 -14
  106. package/dist/esm/lexer/operator.d.ts +2 -2
  107. package/dist/esm/lexer/operator.js +20 -20
  108. package/dist/esm/lexer/rules.d.ts +4 -4
  109. package/dist/esm/lexer/rules.js +69 -69
  110. package/dist/esm/lexer/string.d.ts +2 -2
  111. package/dist/esm/lexer/string.js +177 -177
  112. package/dist/esm/lexer/symbol.d.ts +2 -2
  113. package/dist/esm/lexer/symbol.js +14 -14
  114. package/dist/esm/lexer/token.d.ts +3 -3
  115. package/dist/esm/lexer/token.js +60 -60
  116. package/dist/esm/lexer/types.d.ts +142 -142
  117. package/dist/esm/lexer/types.js +1 -1
  118. package/dist/esm/parser/cursor.d.ts +2 -2
  119. package/dist/esm/parser/cursor.js +9 -9
  120. package/dist/esm/parser/index.d.ts +3 -3
  121. package/dist/esm/parser/index.js +3 -3
  122. package/dist/esm/parser/tree.d.ts +4 -4
  123. package/dist/esm/parser/tree.js +241 -241
  124. package/dist/esm/parser/types.d.ts +33 -33
  125. package/dist/esm/parser/types.js +1 -1
  126. package/dist/esm/query/builder.d.ts +144 -144
  127. package/dist/esm/query/builder.js +304 -304
  128. package/dist/esm/query/handler.d.ts +2 -2
  129. package/dist/esm/query/handler.js +6 -6
  130. package/dist/esm/query/index.d.ts +2 -2
  131. package/dist/esm/query/index.js +2 -2
  132. package/dist/esm/query/matchers/abstract-matcher.d.ts +9 -9
  133. package/dist/esm/query/matchers/abstract-matcher.js +32 -32
  134. package/dist/esm/query/matchers/alt-matcher.d.ts +10 -10
  135. package/dist/esm/query/matchers/alt-matcher.js +29 -29
  136. package/dist/esm/query/matchers/anchor-matcher.d.ts +17 -17
  137. package/dist/esm/query/matchers/anchor-matcher.js +44 -44
  138. package/dist/esm/query/matchers/comment-matcher.d.ts +10 -10
  139. package/dist/esm/query/matchers/comment-matcher.js +35 -35
  140. package/dist/esm/query/matchers/index.d.ts +6 -6
  141. package/dist/esm/query/matchers/index.js +6 -6
  142. package/dist/esm/query/matchers/many-matcher.d.ts +13 -13
  143. package/dist/esm/query/matchers/many-matcher.js +57 -57
  144. package/dist/esm/query/matchers/num-matcher.d.ts +8 -8
  145. package/dist/esm/query/matchers/num-matcher.js +30 -30
  146. package/dist/esm/query/matchers/op-matcher.d.ts +8 -8
  147. package/dist/esm/query/matchers/op-matcher.js +30 -30
  148. package/dist/esm/query/matchers/seq-matcher.d.ts +14 -14
  149. package/dist/esm/query/matchers/seq-matcher.js +72 -72
  150. package/dist/esm/query/matchers/str-matcher.d.ts +38 -38
  151. package/dist/esm/query/matchers/str-matcher.js +102 -102
  152. package/dist/esm/query/matchers/sym-matcher.d.ts +8 -8
  153. package/dist/esm/query/matchers/sym-matcher.js +30 -30
  154. package/dist/esm/query/matchers/tree-matcher.d.ts +23 -23
  155. package/dist/esm/query/matchers/tree-matcher.js +117 -117
  156. package/dist/esm/query/options.d.ts +10 -10
  157. package/dist/esm/query/options.js +139 -139
  158. package/dist/esm/query/regex.d.ts +1 -1
  159. package/dist/esm/query/regex.js +9 -9
  160. package/dist/esm/query/types.d.ts +100 -100
  161. package/dist/esm/query/types.js +1 -1
  162. package/dist/esm/util/clone.d.ts +1 -1
  163. package/dist/esm/util/clone.js +1 -1
  164. package/dist/esm/util/regex.d.ts +1 -1
  165. package/dist/esm/util/regex.js +3 -3
  166. package/package.json +3 -3
@@ -1,118 +1,118 @@
1
- import { isTree } from '../../parser';
2
- import { safeHandler } from '../handler';
3
- import { AbstractMatcher } from './abstract-matcher';
4
- export class TreeMatcher extends AbstractMatcher {
5
- constructor(config) {
6
- var _a, _b, _c;
7
- super();
8
- this.walkDepth = 0;
9
- this.matchCount = 0;
10
- this.type = (_a = config.type) !== null && _a !== void 0 ? _a : null;
11
- this.startsWithValue = (_b = config.startsWith) !== null && _b !== void 0 ? _b : null;
12
- this.endsWithValue = (_c = config.endsWith) !== null && _c !== void 0 ? _c : null;
13
- this.matcher = config.matcher;
14
- this.maxDepth =
15
- typeof config.maxDepth === 'number' && config.maxDepth > 0
16
- ? config.maxDepth
17
- : 1024;
18
- this.maxMatches =
19
- typeof config.maxMatches === 'number' && config.maxMatches > 0
20
- ? config.maxMatches
21
- : 1024 * 1024;
22
- this.preHandler = safeHandler(config.preHandler);
23
- this.postHandler = safeHandler(config.postHandler);
24
- }
25
- walkToNextSignificantNode(cursor) {
26
- const downCursor = cursor.down;
27
- if (downCursor && this.walkDepth < this.maxDepth) {
28
- this.walkDepth += 1;
29
- return downCursor;
30
- }
31
- let rightCursor = cursor.right;
32
- if (rightCursor) {
33
- rightCursor = this.matcher
34
- ? this.matcher.seekNext(rightCursor)
35
- : this.seekNext(rightCursor);
36
- if (rightCursor) {
37
- return rightCursor;
38
- }
39
- }
40
- const canMoveUp = this.walkDepth > 1;
41
- let upperCursor = canMoveUp ? cursor.up : undefined;
42
- while (upperCursor && canMoveUp) {
43
- rightCursor = upperCursor.right;
44
- if (rightCursor) {
45
- rightCursor = this.matcher
46
- ? this.matcher.seekNext(rightCursor)
47
- : this.seekNext(rightCursor);
48
- if (rightCursor) {
49
- upperCursor = rightCursor;
50
- break;
51
- }
52
- }
53
- upperCursor = upperCursor.up;
54
- }
55
- if (upperCursor) {
56
- this.walkDepth -= 1;
57
- return upperCursor;
58
- }
59
- return undefined;
60
- }
61
- walkToNextMatch(context, cursor) {
62
- if (!cursor || !this.matcher) {
63
- return undefined;
64
- }
65
- let nextCursor = this.walkToNextSignificantNode(cursor);
66
- while (nextCursor) {
67
- const match = this.matcher.match({ cursor: nextCursor, context });
68
- if (match) {
69
- this.matchCount += 1;
70
- return match;
71
- }
72
- nextCursor = this.walkToNextSignificantNode(nextCursor);
73
- }
74
- return undefined;
75
- }
76
- match(checkpoint) {
77
- this.walkDepth = 0;
78
- this.matchCount = 0;
79
- const rootCursor = this.seekNext(checkpoint.cursor);
80
- const rootNode = rootCursor.node;
81
- if (isTree(rootNode)) {
82
- if (this.type && this.type !== rootNode.type) {
83
- return null;
84
- }
85
- if (this.type === 'wrapped-tree') {
86
- const currentTree = rootNode;
87
- if (this.startsWithValue &&
88
- currentTree.startsWith.value !== this.startsWithValue) {
89
- return null;
90
- }
91
- if (this.endsWithValue &&
92
- currentTree.endsWith.value !== this.endsWithValue) {
93
- return null;
94
- }
95
- }
96
- let context = checkpoint.context;
97
- context = this.preHandler(context, rootNode);
98
- if (this.matcher) {
99
- let nextMatch = this.walkToNextMatch(context, rootCursor);
100
- while (nextMatch) {
101
- context = nextMatch.context;
102
- if (this.matchCount === this.maxMatches) {
103
- break;
104
- }
105
- nextMatch = this.walkToNextMatch(context, nextMatch.cursor);
106
- }
107
- if (this.matchCount === 0) {
108
- return null;
109
- }
110
- }
111
- context = this.postHandler(context, rootNode);
112
- const cursor = rootNode.type === 'root-tree' ? rootCursor : this.moveRight(rootCursor);
113
- return { context, cursor };
114
- }
115
- return null;
116
- }
117
- }
1
+ import { isTree } from '../../parser';
2
+ import { safeHandler } from '../handler';
3
+ import { AbstractMatcher } from './abstract-matcher';
4
+ export class TreeMatcher extends AbstractMatcher {
5
+ constructor(config) {
6
+ var _a, _b, _c;
7
+ super();
8
+ this.walkDepth = 0;
9
+ this.matchCount = 0;
10
+ this.type = (_a = config.type) !== null && _a !== void 0 ? _a : null;
11
+ this.startsWithValue = (_b = config.startsWith) !== null && _b !== void 0 ? _b : null;
12
+ this.endsWithValue = (_c = config.endsWith) !== null && _c !== void 0 ? _c : null;
13
+ this.matcher = config.matcher;
14
+ this.maxDepth =
15
+ typeof config.maxDepth === 'number' && config.maxDepth > 0
16
+ ? config.maxDepth
17
+ : 1024;
18
+ this.maxMatches =
19
+ typeof config.maxMatches === 'number' && config.maxMatches > 0
20
+ ? config.maxMatches
21
+ : 1024 * 1024;
22
+ this.preHandler = safeHandler(config.preHandler);
23
+ this.postHandler = safeHandler(config.postHandler);
24
+ }
25
+ walkToNextSignificantNode(cursor) {
26
+ const downCursor = cursor.down;
27
+ if (downCursor && this.walkDepth < this.maxDepth) {
28
+ this.walkDepth += 1;
29
+ return downCursor;
30
+ }
31
+ let rightCursor = cursor.right;
32
+ if (rightCursor) {
33
+ rightCursor = this.matcher
34
+ ? this.matcher.seekNext(rightCursor)
35
+ : this.seekNext(rightCursor);
36
+ if (rightCursor) {
37
+ return rightCursor;
38
+ }
39
+ }
40
+ const canMoveUp = this.walkDepth > 1;
41
+ let upperCursor = canMoveUp ? cursor.up : undefined;
42
+ while (upperCursor && canMoveUp) {
43
+ rightCursor = upperCursor.right;
44
+ if (rightCursor) {
45
+ rightCursor = this.matcher
46
+ ? this.matcher.seekNext(rightCursor)
47
+ : this.seekNext(rightCursor);
48
+ if (rightCursor) {
49
+ upperCursor = rightCursor;
50
+ break;
51
+ }
52
+ }
53
+ upperCursor = upperCursor.up;
54
+ }
55
+ if (upperCursor) {
56
+ this.walkDepth -= 1;
57
+ return upperCursor;
58
+ }
59
+ return undefined;
60
+ }
61
+ walkToNextMatch(context, cursor) {
62
+ if (!cursor || !this.matcher) {
63
+ return undefined;
64
+ }
65
+ let nextCursor = this.walkToNextSignificantNode(cursor);
66
+ while (nextCursor) {
67
+ const match = this.matcher.match({ cursor: nextCursor, context });
68
+ if (match) {
69
+ this.matchCount += 1;
70
+ return match;
71
+ }
72
+ nextCursor = this.walkToNextSignificantNode(nextCursor);
73
+ }
74
+ return undefined;
75
+ }
76
+ match(checkpoint) {
77
+ this.walkDepth = 0;
78
+ this.matchCount = 0;
79
+ const rootCursor = this.seekNext(checkpoint.cursor);
80
+ const rootNode = rootCursor.node;
81
+ if (isTree(rootNode)) {
82
+ if (this.type && this.type !== rootNode.type) {
83
+ return null;
84
+ }
85
+ if (this.type === 'wrapped-tree') {
86
+ const currentTree = rootNode;
87
+ if (this.startsWithValue &&
88
+ currentTree.startsWith.value !== this.startsWithValue) {
89
+ return null;
90
+ }
91
+ if (this.endsWithValue &&
92
+ currentTree.endsWith.value !== this.endsWithValue) {
93
+ return null;
94
+ }
95
+ }
96
+ let context = checkpoint.context;
97
+ context = this.preHandler(context, rootNode);
98
+ if (this.matcher) {
99
+ let nextMatch = this.walkToNextMatch(context, rootCursor);
100
+ while (nextMatch) {
101
+ context = nextMatch.context;
102
+ if (this.matchCount === this.maxMatches) {
103
+ break;
104
+ }
105
+ nextMatch = this.walkToNextMatch(context, nextMatch.cursor);
106
+ }
107
+ if (this.matchCount === 0) {
108
+ return null;
109
+ }
110
+ }
111
+ context = this.postHandler(context, rootNode);
112
+ const cursor = rootNode.type === 'root-tree' ? rootCursor : this.moveRight(rootCursor);
113
+ return { context, cursor };
114
+ }
115
+ return null;
116
+ }
117
+ }
118
118
  //# sourceMappingURL=tree-matcher.js.map
@@ -1,11 +1,11 @@
1
- import type { Node, TreeType } from '../parser/types';
2
- import type { StrContentMatcherHandler } from './matchers/str-matcher';
3
- import type { CommentMatcherHandler, CommentMatcherOptions, CommentMatcherValue, ManyBuilderOpts, NumMatcherHandler, NumMatcherOptions, NumMatcherValue, OpMatcherHandler, OpMatcherOptions, OpMatcherValue, QueryBuilder, StrBuilderOptions, StrBuilderOptionsBase, SymMatcherHandler, SymMatcherOptions, SymMatcherValue, TreeBuilderOptions } from './types';
4
- export declare function coerceSymOptions<Ctx>(arg1?: SymMatcherValue | SymMatcherOptions<Ctx> | SymMatcherHandler<Ctx>, arg2?: SymMatcherHandler<Ctx>): SymMatcherOptions<Ctx>;
5
- export declare function coerceOpOptions<Ctx>(arg1?: OpMatcherValue | OpMatcherOptions<Ctx> | OpMatcherHandler<Ctx>, arg2?: OpMatcherHandler<Ctx>): OpMatcherOptions<Ctx>;
6
- export declare function coerceCommentOptions<Ctx>(arg1?: CommentMatcherValue | CommentMatcherOptions<Ctx> | CommentMatcherHandler<Ctx>, arg2?: CommentMatcherHandler<Ctx>): CommentMatcherOptions<Ctx>;
7
- export declare function coerceNumOptions<Ctx>(arg1?: NumMatcherValue | NumMatcherOptions<Ctx> | NumMatcherHandler<Ctx>, arg2?: NumMatcherHandler<Ctx>): NumMatcherOptions<Ctx>;
8
- export declare function coerceManyOptions<Ctx>(builder: QueryBuilder<Ctx, Node>, arg2?: number, arg3?: number): ManyBuilderOpts<Ctx>;
9
- export declare function coerceTreeOptions<Ctx>(arg1: TreeBuilderOptions<Ctx> | TreeType | undefined): TreeBuilderOptions<Ctx>;
10
- export declare function coerceStrOptions<Ctx>(arg1: string | RegExp | StrContentMatcherHandler<Ctx> | StrBuilderOptionsBase<Ctx> | undefined, arg2: StrContentMatcherHandler<Ctx> | undefined): StrBuilderOptions<Ctx>;
1
+ import type { Node, TreeType } from '../parser/types';
2
+ import type { StrContentMatcherHandler } from './matchers/str-matcher';
3
+ import type { CommentMatcherHandler, CommentMatcherOptions, CommentMatcherValue, ManyBuilderOpts, NumMatcherHandler, NumMatcherOptions, NumMatcherValue, OpMatcherHandler, OpMatcherOptions, OpMatcherValue, QueryBuilder, StrBuilderOptions, StrBuilderOptionsBase, SymMatcherHandler, SymMatcherOptions, SymMatcherValue, TreeBuilderOptions } from './types';
4
+ export declare function coerceSymOptions<Ctx>(arg1?: SymMatcherValue | SymMatcherOptions<Ctx> | SymMatcherHandler<Ctx>, arg2?: SymMatcherHandler<Ctx>): SymMatcherOptions<Ctx>;
5
+ export declare function coerceOpOptions<Ctx>(arg1?: OpMatcherValue | OpMatcherOptions<Ctx> | OpMatcherHandler<Ctx>, arg2?: OpMatcherHandler<Ctx>): OpMatcherOptions<Ctx>;
6
+ export declare function coerceCommentOptions<Ctx>(arg1?: CommentMatcherValue | CommentMatcherOptions<Ctx> | CommentMatcherHandler<Ctx>, arg2?: CommentMatcherHandler<Ctx>): CommentMatcherOptions<Ctx>;
7
+ export declare function coerceNumOptions<Ctx>(arg1?: NumMatcherValue | NumMatcherOptions<Ctx> | NumMatcherHandler<Ctx>, arg2?: NumMatcherHandler<Ctx>): NumMatcherOptions<Ctx>;
8
+ export declare function coerceManyOptions<Ctx>(builder: QueryBuilder<Ctx, Node>, arg2?: number, arg3?: number): ManyBuilderOpts<Ctx>;
9
+ export declare function coerceTreeOptions<Ctx>(arg1: TreeBuilderOptions<Ctx> | TreeType | undefined): TreeBuilderOptions<Ctx>;
10
+ export declare function coerceStrOptions<Ctx>(arg1: string | RegExp | StrContentMatcherHandler<Ctx> | StrBuilderOptionsBase<Ctx> | undefined, arg2: StrContentMatcherHandler<Ctx> | undefined): StrBuilderOptions<Ctx>;
11
11
  //# sourceMappingURL=options.d.ts.map
@@ -1,140 +1,140 @@
1
- import { isRegex } from './regex';
2
- export function coerceSymOptions(arg1, arg2) {
3
- if (typeof arg1 === 'string' || isRegex(arg1)) {
4
- return {
5
- value: arg1,
6
- handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
7
- };
8
- }
9
- if (typeof arg1 === 'function') {
10
- return {
11
- value: null,
12
- handler: arg1,
13
- };
14
- }
15
- if (arg1 !== null && typeof arg1 === 'object') {
16
- return arg1;
17
- }
18
- return { value: null, handler: null };
19
- }
20
- export function coerceOpOptions(arg1, arg2) {
21
- if (typeof arg1 === 'string' || isRegex(arg1)) {
22
- return {
23
- value: arg1,
24
- handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
25
- };
26
- }
27
- if (typeof arg1 === 'function') {
28
- return {
29
- value: null,
30
- handler: arg1,
31
- };
32
- }
33
- if (arg1 !== null && typeof arg1 === 'object') {
34
- return arg1;
35
- }
36
- return { value: null, handler: null };
37
- }
38
- export function coerceCommentOptions(arg1, arg2) {
39
- if (typeof arg1 === 'string' || isRegex(arg1)) {
40
- return {
41
- value: arg1,
42
- handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
43
- };
44
- }
45
- if (typeof arg1 === 'function') {
46
- return {
47
- value: null,
48
- handler: arg1,
49
- };
50
- }
51
- if (arg1 !== null && typeof arg1 === 'object') {
52
- return arg1;
53
- }
54
- return { value: null, handler: null };
55
- }
56
- export function coerceNumOptions(arg1, arg2) {
57
- if (typeof arg1 === 'string' || isRegex(arg1)) {
58
- return {
59
- value: arg1,
60
- handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
61
- };
62
- }
63
- if (typeof arg1 === 'function') {
64
- return {
65
- value: null,
66
- handler: arg1,
67
- };
68
- }
69
- if (arg1 !== null && typeof arg1 === 'object') {
70
- return arg1;
71
- }
72
- return { value: null, handler: null };
73
- }
74
- export function coerceManyOptions(builder, arg2, arg3) {
75
- if (typeof arg2 === 'number' && typeof arg3 === 'number') {
76
- return { builder, min: arg2, max: arg3 };
77
- }
78
- return { builder, min: 1, max: null };
79
- }
80
- export function coerceTreeOptions(arg1) {
81
- if (typeof arg1 === 'string') {
82
- return { type: arg1 };
83
- }
84
- else if (!arg1) {
85
- return { type: null };
86
- }
87
- else {
88
- return arg1;
89
- }
90
- }
91
- export function coerceStrOptions(arg1, arg2) {
92
- if (typeof arg1 === 'string' || isRegex(arg1)) {
93
- if (arg1 === '') {
94
- return {
95
- type: 'str-tree',
96
- match: [],
97
- postHandler: arg2
98
- ? (ctx, tree) => arg2(ctx, {
99
- ...tree.startsWith,
100
- type: 'string-value',
101
- value: arg1,
102
- })
103
- : null,
104
- };
105
- }
106
- return {
107
- type: 'str-content',
108
- match: arg1,
109
- handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
110
- };
111
- }
112
- else if (typeof arg1 === 'function') {
113
- return {
114
- type: 'str-content',
115
- match: null,
116
- handler: arg1,
117
- };
118
- }
119
- else if (arg1) {
120
- if (arg1['handler'] ||
121
- typeof arg1.match === 'string' ||
122
- isRegex(arg1.match)) {
123
- return {
124
- type: 'str-content',
125
- ...arg1,
126
- };
127
- }
128
- return {
129
- type: 'str-tree',
130
- ...arg1,
131
- };
132
- }
133
- return {
134
- type: 'str-tree',
135
- match: null,
136
- preHandler: null,
137
- postHandler: null,
138
- };
139
- }
1
+ import { isRegex } from './regex';
2
+ export function coerceSymOptions(arg1, arg2) {
3
+ if (typeof arg1 === 'string' || isRegex(arg1)) {
4
+ return {
5
+ value: arg1,
6
+ handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
7
+ };
8
+ }
9
+ if (typeof arg1 === 'function') {
10
+ return {
11
+ value: null,
12
+ handler: arg1,
13
+ };
14
+ }
15
+ if (arg1 !== null && typeof arg1 === 'object') {
16
+ return arg1;
17
+ }
18
+ return { value: null, handler: null };
19
+ }
20
+ export function coerceOpOptions(arg1, arg2) {
21
+ if (typeof arg1 === 'string' || isRegex(arg1)) {
22
+ return {
23
+ value: arg1,
24
+ handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
25
+ };
26
+ }
27
+ if (typeof arg1 === 'function') {
28
+ return {
29
+ value: null,
30
+ handler: arg1,
31
+ };
32
+ }
33
+ if (arg1 !== null && typeof arg1 === 'object') {
34
+ return arg1;
35
+ }
36
+ return { value: null, handler: null };
37
+ }
38
+ export function coerceCommentOptions(arg1, arg2) {
39
+ if (typeof arg1 === 'string' || isRegex(arg1)) {
40
+ return {
41
+ value: arg1,
42
+ handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
43
+ };
44
+ }
45
+ if (typeof arg1 === 'function') {
46
+ return {
47
+ value: null,
48
+ handler: arg1,
49
+ };
50
+ }
51
+ if (arg1 !== null && typeof arg1 === 'object') {
52
+ return arg1;
53
+ }
54
+ return { value: null, handler: null };
55
+ }
56
+ export function coerceNumOptions(arg1, arg2) {
57
+ if (typeof arg1 === 'string' || isRegex(arg1)) {
58
+ return {
59
+ value: arg1,
60
+ handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
61
+ };
62
+ }
63
+ if (typeof arg1 === 'function') {
64
+ return {
65
+ value: null,
66
+ handler: arg1,
67
+ };
68
+ }
69
+ if (arg1 !== null && typeof arg1 === 'object') {
70
+ return arg1;
71
+ }
72
+ return { value: null, handler: null };
73
+ }
74
+ export function coerceManyOptions(builder, arg2, arg3) {
75
+ if (typeof arg2 === 'number' && typeof arg3 === 'number') {
76
+ return { builder, min: arg2, max: arg3 };
77
+ }
78
+ return { builder, min: 1, max: null };
79
+ }
80
+ export function coerceTreeOptions(arg1) {
81
+ if (typeof arg1 === 'string') {
82
+ return { type: arg1 };
83
+ }
84
+ else if (!arg1) {
85
+ return { type: null };
86
+ }
87
+ else {
88
+ return arg1;
89
+ }
90
+ }
91
+ export function coerceStrOptions(arg1, arg2) {
92
+ if (typeof arg1 === 'string' || isRegex(arg1)) {
93
+ if (arg1 === '') {
94
+ return {
95
+ type: 'str-tree',
96
+ match: [],
97
+ postHandler: arg2
98
+ ? (ctx, tree) => arg2(ctx, {
99
+ ...tree.startsWith,
100
+ type: 'string-value',
101
+ value: arg1,
102
+ })
103
+ : null,
104
+ };
105
+ }
106
+ return {
107
+ type: 'str-content',
108
+ match: arg1,
109
+ handler: arg2 !== null && arg2 !== void 0 ? arg2 : null,
110
+ };
111
+ }
112
+ else if (typeof arg1 === 'function') {
113
+ return {
114
+ type: 'str-content',
115
+ match: null,
116
+ handler: arg1,
117
+ };
118
+ }
119
+ else if (arg1) {
120
+ if (arg1['handler'] ||
121
+ typeof arg1.match === 'string' ||
122
+ isRegex(arg1.match)) {
123
+ return {
124
+ type: 'str-content',
125
+ ...arg1,
126
+ };
127
+ }
128
+ return {
129
+ type: 'str-tree',
130
+ ...arg1,
131
+ };
132
+ }
133
+ return {
134
+ type: 'str-tree',
135
+ match: null,
136
+ preHandler: null,
137
+ postHandler: null,
138
+ };
139
+ }
140
140
  //# sourceMappingURL=options.js.map
@@ -1,2 +1,2 @@
1
- export declare function isRegex(input: unknown): input is RegExp;
1
+ export declare function isRegex(input: unknown): input is RegExp;
2
2
  //# sourceMappingURL=regex.d.ts.map
@@ -1,10 +1,10 @@
1
- export function isRegex(input) {
2
- if (input instanceof RegExp) {
3
- return true;
4
- }
5
- if (input && typeof input === 'object' && input.constructor.name === 'RE2') {
6
- return true;
7
- }
8
- return false;
9
- }
1
+ export function isRegex(input) {
2
+ if (input instanceof RegExp) {
3
+ return true;
4
+ }
5
+ if (input && typeof input === 'object' && input.constructor.name === 'RE2') {
6
+ return true;
7
+ }
8
+ return false;
9
+ }
10
10
  //# sourceMappingURL=regex.js.map