rregex 1.0.0 → 1.0.1

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.
package/lib/commonjs.d.ts CHANGED
@@ -1,51 +1,420 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * @param {string} text
5
+ * @returns {string}
6
+ */
7
+ export function escape(text: string): string;
8
+ /**
4
9
  * @returns {any}
5
10
  */
6
11
  export function get_metadata(): any;
12
+
13
+ export type Hir = {
14
+ '@type': 'struct'
15
+ '@name': 'regex_syntax::hir::Hir'
16
+ bold: boolean;
17
+ italic: boolean;
18
+ size: number;
19
+ }
20
+
21
+
22
+
23
+ export type HirKind =
24
+ | HirKindEmptyVariant
25
+ | HirKindLiteralVariant
26
+ | HirKindClassVariant
27
+ | HirKindAnchorVariant
28
+ | HirKindWordBoundaryVariant
29
+ | HirKindRepetitionVariant
30
+ | HirKindGroupVariant
31
+ | HirKindConcatVariant
32
+ | HirKindAlternationVariant
33
+
34
+ export type HirKindEmptyVariant = {
35
+ '@type': 'struct'
36
+ '@name': 'regex_syntax::hir::HirKind'
37
+ '@variant': 'Empty'
38
+ }
39
+
40
+ export type HirKindLiteralVariant = {
41
+ '@type': 'struct'
42
+ '@name': 'regex_syntax::hir::HirKind'
43
+ '@variant': 'Literal'
44
+ 'value': Literal
45
+ }
46
+
47
+ export type HirKindClassVariant = {
48
+ '@type': 'struct'
49
+ '@name': 'regex_syntax::hir::HirKind'
50
+ '@variant': 'Class'
51
+ 'value': Class
52
+ }
53
+
54
+ export type HirKindAnchorVariant = {
55
+ '@type': 'struct'
56
+ '@name': 'regex_syntax::hir::HirKind'
57
+ '@variant': 'Anchor'
58
+ 'value': Anchor
59
+ }
60
+
61
+ export type HirKindWordBoundaryVariant = {
62
+ '@type': 'struct'
63
+ '@name': 'regex_syntax::hir::HirKind'
64
+ '@variant': 'WordBoundary'
65
+ 'value': WordBoundary
66
+ }
67
+
68
+ export type HirKindRepetitionVariant = {
69
+ '@type': 'struct'
70
+ '@name': 'regex_syntax::hir::HirKind'
71
+ '@variant': 'Repetition'
72
+ 'value': Repetition
73
+ }
74
+
75
+ export type HirKindGroupVariant = {
76
+ '@type': 'struct'
77
+ '@name': 'regex_syntax::hir::HirKind'
78
+ '@variant': 'Group'
79
+ 'value': Group
80
+ }
81
+
82
+ export type HirKindConcatVariant = {
83
+ '@type': 'struct'
84
+ '@name': 'regex_syntax::hir::HirKind'
85
+ '@variant': 'Concat'
86
+ 'value': Hir[]
87
+ }
88
+
89
+ export type HirKindAlternationVariant = {
90
+ '@type': 'struct'
91
+ '@name': 'regex_syntax::hir::HirKind'
92
+ '@variant': 'Alternation'
93
+ 'value': Hir[]
94
+ }
95
+
96
+
97
+
98
+ export type Literal =
99
+ | LiteralUnicodeVariant
100
+ | LiteralByteVariant
101
+
102
+ export type LiteralUnicodeVariant = {
103
+ '@type': 'struct'
104
+ '@name': 'regex_syntax::hir::Literal'
105
+ '@variant': 'Unicode'
106
+ 'value': string
107
+ }
108
+
109
+ export type LiteralByteVariant = {
110
+ '@type': 'struct'
111
+ '@name': 'regex_syntax::hir::Literal'
112
+ '@variant': 'Byte'
113
+ 'value': number
114
+ }
115
+
116
+
117
+
118
+ export type Class =
119
+ | ClassUnicodeVariant
120
+ | ClassByteVariant
121
+
122
+ export type ClassUnicodeVariant = {
123
+ '@type': 'struct'
124
+ '@name': 'regex_syntax::hir::Class'
125
+ '@variant': 'Unicode'
126
+ 'value': ClassUnicode
127
+ }
128
+
129
+ export type ClassByteVariant = {
130
+ '@type': 'struct'
131
+ '@name': 'regex_syntax::hir::Class'
132
+ '@variant': 'Bytes'
133
+ 'value': ClassBytes
134
+ }
135
+
136
+
137
+
138
+ export type ClassUnicode = {
139
+ '@type': 'struct'
140
+ '@name': 'regex_syntax::hir::ClassUnicode'
141
+ 'ranges': ClassUnicodeRange[]
142
+ }
143
+
144
+
145
+
146
+ export type ClassUnicodeRange = {
147
+ '@type': 'struct'
148
+ '@name': 'regex_syntax::hir::ClassUnicodeRange'
149
+ start: string
150
+ end: string
151
+ }
152
+
153
+
154
+
155
+ export type ClassBytes = {
156
+ '@type': 'struct'
157
+ '@name': 'regex_syntax::hir::ClassBytes'
158
+ ranges: ClassBytesRange[]
159
+ }
160
+
161
+
162
+
163
+ export type ClassBytesRange = {
164
+ '@type': 'struct'
165
+ '@name': 'regex_syntax::hir::ClassBytesRange'
166
+ start: number
167
+ end: number
168
+ }
169
+
170
+
171
+
172
+ export type Anchor =
173
+ | AnchorStartLineVariant
174
+ | AnchorEndLineVariant
175
+ | AnchorStartTextVariant
176
+ | AnchorEndTextVariant
177
+
178
+ export type AnchorStartLineVariant = {
179
+ '@type': 'struct'
180
+ '@name': 'regex_syntax::hir::Anchor'
181
+ '@variant': 'StartLine'
182
+ }
183
+
184
+ export type AnchorEndLineVariant = {
185
+ '@type': 'struct'
186
+ '@name': 'regex_syntax::hir::Anchor'
187
+ '@variant': 'EndLine'
188
+ }
189
+
190
+ export type AnchorStartTextVariant = {
191
+ '@type': 'struct'
192
+ '@name': 'regex_syntax::hir::Anchor'
193
+ '@variant': 'StartText'
194
+ }
195
+
196
+ export type AnchorEndTextVariant = {
197
+ '@type': 'struct'
198
+ '@name': 'regex_syntax::hir::Anchor'
199
+ '@variant': 'EndText'
200
+ }
201
+
202
+
203
+
204
+ export type WordBoundary =
205
+ | WordBoundaryAsciiVariant
206
+ | WordBoundaryAsciiNegateVariant
207
+ | WordBoundaryUnicodeVariant
208
+ | WordBoundaryUnicodeNegateVariant
209
+
210
+ export type WordBoundaryAsciiVariant = {
211
+ '@type': 'struct'
212
+ '@name': 'regex_syntax::hir::WordBoundary'
213
+ '@variant': 'Ascii'
214
+ }
215
+
216
+ export type WordBoundaryAsciiNegateVariant = {
217
+ '@type': 'struct'
218
+ '@name': 'regex_syntax::hir::WordBoundary'
219
+ '@variant': 'AsciiNegate'
220
+ }
221
+
222
+ export type WordBoundaryUnicodeVariant = {
223
+ '@type': 'struct'
224
+ '@name': 'regex_syntax::hir::WordBoundary'
225
+ '@variant': 'Unicode'
226
+ }
227
+
228
+ export type WordBoundaryUnicodeNegateVariant = {
229
+ '@type': 'struct'
230
+ '@name': 'regex_syntax::hir::WordBoundary'
231
+ '@variant': 'UnicodeNegate'
232
+ }
233
+
234
+
235
+
236
+ export type Repetition = {
237
+ '@type': 'struct'
238
+ '@name': 'regex_syntax::hir::Repetition'
239
+ greedy: boolean
240
+ kind: RepetitionKind
241
+ hir: Hir
242
+ }
243
+
244
+
245
+
246
+ export type RepetitionKind =
247
+ | RepetitionKindZeroOrOneVariant
248
+ | RepetitionKindZeroOrMoreVariant
249
+ | RepetitionKindOneOrMoreVariant
250
+ | RepetitionKindRangeVariant
251
+
252
+ export type RepetitionKindZeroOrOneVariant = {
253
+ '@type': 'struct'
254
+ '@name': 'regex_syntax::hir::Repetition'
255
+ '@variant': 'ZeroOrOne'
256
+ }
257
+
258
+ export type RepetitionKindZeroOrMoreVariant = {
259
+ '@type': 'struct'
260
+ '@name': 'regex_syntax::hir::Repetition'
261
+ '@variant': 'ZeroOrMore'
262
+ }
263
+
264
+ export type RepetitionKindOneOrMoreVariant = {
265
+ '@type': 'struct'
266
+ '@name': 'regex_syntax::hir::Repetition'
267
+ '@variant': 'OneOrMore'
268
+ }
269
+
270
+ export type RepetitionKindRangeVariant = {
271
+ '@type': 'struct'
272
+ '@name': 'regex_syntax::hir::Repetition'
273
+ '@variant': 'Range'
274
+ value: RepetitionRange
275
+ }
276
+
277
+
278
+
279
+ export type RepetitionRange =
280
+ | RepetitionRangeExactlyVariant
281
+ | RepetitionRangeAtLeastVariant
282
+ | RepetitionRangeBoundedVariant
283
+
284
+ export type RepetitionRangeExactlyVariant = {
285
+ '@type': 'struct'
286
+ '@name': 'regex_syntax::hir::RepetitionRange'
287
+ '@variant': 'Exactly'
288
+ value: number
289
+ }
290
+
291
+ export type RepetitionRangeAtLeastVariant = {
292
+ '@type': 'struct'
293
+ '@name': 'regex_syntax::hir::RepetitionRange'
294
+ '@variant': 'AtLeast'
295
+ value: number
296
+ }
297
+
298
+ export type RepetitionRangeBoundedVariant = {
299
+ '@type': 'struct'
300
+ '@name': 'regex_syntax::hir::RepetitionRange'
301
+ '@variant': 'Bounded'
302
+ value: [number, number]
303
+ }
304
+
305
+
306
+
307
+ export type Group = {
308
+ '@type': 'struct'
309
+ '@name': 'regex_syntax::hir::Group'
310
+ kind: GroupKind
311
+ hir: Hir
312
+ }
313
+
314
+
315
+
316
+ export type GroupKind =
317
+ | GroupKindCaptureIndexVariant
318
+ | GroupKindCaptureNameVariant
319
+ | GroupKindNonCapturingVariant
320
+
321
+ export type GroupKindCaptureIndexVariant = {
322
+ '@type': 'struct'
323
+ '@name': 'regex_syntax::hir::GroupKind'
324
+ '@variant': 'CaptureIndex'
325
+ index: number
326
+ }
327
+
328
+ export type GroupKindCaptureNameVariant = {
329
+ '@type': 'struct'
330
+ '@name': 'regex_syntax::hir::GroupKind'
331
+ '@variant': 'CaptureName'
332
+ index: number
333
+ name: string
334
+ }
335
+
336
+ export type GroupKindNonCapturingVariant = {
337
+ '@type': 'struct'
338
+ '@name': 'regex_syntax::hir::GroupKind'
339
+ '@variant': 'NonCapturing'
340
+ }
341
+
342
+
343
+
344
+ export type Match = {
345
+ start: number
346
+ end: number
347
+ value: string
348
+ }
349
+
350
+
7
351
  /**
352
+ * A compiled regular expression for matching Unicode strings.
353
+ * @see https://docs.rs/regex/latest/regex/
8
354
  */
9
- export class RRegExp {
355
+ export class RRegex {
10
356
  free(): void;
11
357
  /**
358
+ * Compiles a regular expression. Once compiled, it can be used repeatedly to search, split or replace text in a string.
359
+ * If an invalid expression is given, then an error is returned.
12
360
  * @param {string} re
13
361
  */
14
362
  constructor(re: string);
15
363
  /**
364
+ * Returns true if and only if there is a match for the regex in the string given.
365
+ * It is recommended to use this method if all you need to do is test a match, since the underlying matching engine may be able to do less work.
366
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match
16
367
  * @param {string} text
17
368
  * @returns {boolean}
18
369
  */
19
- is_match(text: string): boolean;
370
+ isMatch(text: string): boolean;
20
371
  /**
372
+ * Returns the same as is_match, but starts the search at the given offset.
373
+ * The significance of the starting point is that it takes the surrounding context into consideration. For example, the `\A` anchor can only match when `start == 0`.
374
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at
21
375
  * @param {string} text
22
376
  * @param {number} start
23
377
  * @returns {boolean}
24
378
  */
25
- is_match_at(text: string, start: number): boolean;
379
+ isMatchAt(text: string, start: number): boolean;
26
380
  /**
381
+ * Returns the start and end byte range of the leftmost-first match in `text`. If no match exists, then `undefined` is returned.
382
+ * Note that this should only be used if you want to discover the position of the match. Testing the existence of a match is faster if you use `is_match`.
383
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find
27
384
  * @param {string} text
28
385
  * @returns {any}
29
386
  */
30
- find(text: string): any;
387
+ find(text: string): Match | undefined;
31
388
  /**
389
+ * Returns the same as find, but starts the search at the given offset.
390
+ * The significance of the starting point is that it takes the surrounding context into consideration. For example, the \A anchor can only match when `start == 0`.
391
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at
32
392
  * @param {string} text
33
393
  * @param {number} start
34
394
  * @returns {any}
35
395
  */
36
- find_at(text: string, start: number): any;
396
+ findAt(text: string, start: number): Match | undefined;
37
397
  /**
398
+ * Returns an array for each successive non-overlapping match in text, returning the start and end byte indices with respect to text.
399
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter
38
400
  * @param {string} text
39
401
  * @returns {any}
40
402
  */
41
- find_all(text: string): any;
403
+ findAll(text: string): Match[];
42
404
  /**
405
+ * Replaces the leftmost-first match with the replacement provided.
406
+ * The replacement can be a regular string (where `$N` and `$name` are expanded to match capture groups) or a function that takes the matches’ `Captures` and returns the replaced string.
407
+ * If no match is found, then a copy of the string is returned unchanged.
408
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace
43
409
  * @param {string} text
44
410
  * @param {string} rep
45
411
  * @returns {string}
46
412
  */
47
413
  replace(text: string, rep: string): string;
48
414
  /**
415
+ * Replaces at most `limit` non-overlapping matches in `text` with the replacement provided. If `limit` is 0, then all non-overlapping matches are replaced.
416
+ * See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
417
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen
49
418
  * @param {string} text
50
419
  * @param {number} limit
51
420
  * @param {string} rep
@@ -53,24 +422,85 @@ export class RRegExp {
53
422
  */
54
423
  replacen(text: string, limit: number, rep: string): string;
55
424
  /**
425
+ * Replaces all non-overlapping matches in `text` with the replacement provided. This is the same as calling `replacen` with `limit` set to `0`.
426
+ * See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
427
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all
56
428
  * @param {string} text
57
429
  * @param {string} rep
58
430
  * @returns {string}
59
431
  */
60
- replace_all(text: string, rep: string): string;
432
+ replaceAll(text: string, rep: string): string;
61
433
  /**
434
+ * Returns an iterator of substrings of `text` delimited by a match of the regular expression. Namely, each element of the iterator corresponds to text that isn’t matched by the regular expression.
435
+ * This method will not copy the text given.
436
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.split
62
437
  * @param {string} text
63
438
  * @returns {any}
64
439
  */
65
- split(text: string): any;
440
+ split(text: string): string[];
66
441
  /**
442
+ * Returns an iterator of at most `limit` substrings of `text` delimited by a match of the regular expression. (A limit of 0 will return no substrings.) Namely, each element of the iterator corresponds to text that isn’t matched by the regular expression. The remainder of the string that is not split will be the last element in the iterator.
443
+ * This method will not copy the text given.
444
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn
67
445
  * @param {string} text
68
446
  * @param {number} limit
69
447
  * @returns {any}
70
448
  */
71
- splitn(text: string, limit: number): any;
449
+ splitn(text: string, limit: number): string[];
72
450
  /**
451
+ * Returns the end location of a match in the text given.
452
+ * This method may have the same performance characteristics as `is_match`, except it provides an end location for a match. In particular, the location returned may be shorter than the proper end of the leftmost-first match.
453
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match
454
+ * @param {string} text
455
+ * @returns {number | undefined}
456
+ */
457
+ shortestMatch(text: string): number | undefined;
458
+ /**
459
+ * Returns the same as shortest_match, but starts the search at the given offset.
460
+ * The significance of the starting point is that it takes the surrounding context into consideration. For example, the \A anchor can only match when `start == 0`.
461
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at
462
+ * @param {string} text
463
+ * @param {number} limit
464
+ * @returns {number | undefined}
465
+ */
466
+ shortestMatchAt(text: string, limit: number): number | undefined;
467
+ /**
468
+ * Return the Regex syntax object
469
+ * @returns {any}
470
+ */
471
+ syntax(): Hir;
472
+ /**
473
+ * Returns a string representing the regular expression
474
+ * @returns {string}
475
+ */
476
+ toString(): string;
477
+ }
478
+ /**
479
+ * Match multiple (possibly overlapping) regular expressions in a single scan.
480
+ * A regex set corresponds to the union of two or more regular expressions. That is, a regex set will match text where at least one of its constituent regular expressions matches. A regex set as its formulated here provides a touch more power: it will also report which regular expressions in the set match. Indeed, this is the key difference between regex sets and a single `Regex` with many alternates, since only one alternate can match at a time.
481
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
482
+ */
483
+ export class RRegexSet {
484
+ free(): void;
485
+ /**
486
+ * Create a new regex set with the given regular expressions.
487
+ * @param {Array<any>} list
488
+ */
489
+ constructor(list: Array<any>);
490
+ /**
491
+ * Returns true if and only if one of the regexes in this set matches the text given.
492
+ * This method should be preferred if you only need to test whether any of the regexes in the set should match, but don’t care about which regexes matched. This is because the underlying matching engine will quit immediately after seeing the first match instead of continuing to find all matches.
493
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.is_match
494
+ * @param {string} text
495
+ * @returns {boolean}
496
+ */
497
+ isMatch(text: string): boolean;
498
+ /**
499
+ * Returns the set of regular expressions that match in the given text.
500
+ * The set returned contains the index of each regular expression that matches in the given text. The index is in correspondence with the order of regular expressions given to RegexSet’s constructor.
501
+ * the set can also be used to iterate over the matched indices.
502
+ * @param {string} text
73
503
  * @returns {any}
74
504
  */
75
- syntax(): any;
505
+ matches(text: string): any;
76
506
  }