rregex 1.2.0 → 1.2.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.
@@ -1,9 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * @param {string} text
5
- * @returns {string}
6
- */
7
3
  export function escape(text: string): string;
8
4
 
9
5
  export type Hir = {
@@ -14,81 +10,6 @@ export type Hir = {
14
10
 
15
11
 
16
12
 
17
- export type HirKind =
18
- | HirKindEmptyVariant
19
- | HirKindLiteralVariant
20
- | HirKindClassVariant
21
- | HirKindAnchorVariant
22
- | HirKindWordBoundaryVariant
23
- | HirKindRepetitionVariant
24
- | HirKindGroupVariant
25
- | HirKindConcatVariant
26
- | HirKindAlternationVariant
27
-
28
- export type HirKindEmptyVariant = {
29
- '@type': 'struct'
30
- '@name': 'regex_syntax::hir::HirKind'
31
- '@variant': 'Empty'
32
- }
33
-
34
- export type HirKindLiteralVariant = {
35
- '@type': 'struct'
36
- '@name': 'regex_syntax::hir::HirKind'
37
- '@variant': 'Literal'
38
- '@values': [Literal]
39
- }
40
-
41
- export type HirKindClassVariant = {
42
- '@type': 'struct'
43
- '@name': 'regex_syntax::hir::HirKind'
44
- '@variant': 'Class'
45
- '@values': [Class]
46
- }
47
-
48
- export type HirKindAnchorVariant = {
49
- '@type': 'struct'
50
- '@name': 'regex_syntax::hir::HirKind'
51
- '@variant': 'Anchor'
52
- '@values': [Anchor]
53
- }
54
-
55
- export type HirKindWordBoundaryVariant = {
56
- '@type': 'struct'
57
- '@name': 'regex_syntax::hir::HirKind'
58
- '@variant': 'WordBoundary'
59
- '@values': [WordBoundary]
60
- }
61
-
62
- export type HirKindRepetitionVariant = {
63
- '@type': 'struct'
64
- '@name': 'regex_syntax::hir::HirKind'
65
- '@variant': 'Repetition'
66
- '@values': [Repetition]
67
- }
68
-
69
- export type HirKindGroupVariant = {
70
- '@type': 'struct'
71
- '@name': 'regex_syntax::hir::HirKind'
72
- '@variant': 'Group'
73
- '@values': [Group]
74
- }
75
-
76
- export type HirKindConcatVariant = {
77
- '@type': 'struct'
78
- '@name': 'regex_syntax::hir::HirKind'
79
- '@variant': 'Concat'
80
- '@values': [Hir[]]
81
- }
82
-
83
- export type HirKindAlternationVariant = {
84
- '@type': 'struct'
85
- '@name': 'regex_syntax::hir::HirKind'
86
- '@variant': 'Alternation'
87
- '@values': [Hir[]]
88
- }
89
-
90
-
91
-
92
13
  export type Literal =
93
14
  | LiteralUnicodeVariant
94
15
  | LiteralByteVariant
@@ -270,6 +191,81 @@ export type RepetitionKindRangeVariant = {
270
191
 
271
192
 
272
193
 
194
+ export type HirKind =
195
+ | HirKindEmptyVariant
196
+ | HirKindLiteralVariant
197
+ | HirKindClassVariant
198
+ | HirKindAnchorVariant
199
+ | HirKindWordBoundaryVariant
200
+ | HirKindRepetitionVariant
201
+ | HirKindGroupVariant
202
+ | HirKindConcatVariant
203
+ | HirKindAlternationVariant
204
+
205
+ export type HirKindEmptyVariant = {
206
+ '@type': 'struct'
207
+ '@name': 'regex_syntax::hir::HirKind'
208
+ '@variant': 'Empty'
209
+ }
210
+
211
+ export type HirKindLiteralVariant = {
212
+ '@type': 'struct'
213
+ '@name': 'regex_syntax::hir::HirKind'
214
+ '@variant': 'Literal'
215
+ '@values': [Literal]
216
+ }
217
+
218
+ export type HirKindClassVariant = {
219
+ '@type': 'struct'
220
+ '@name': 'regex_syntax::hir::HirKind'
221
+ '@variant': 'Class'
222
+ '@values': [Class]
223
+ }
224
+
225
+ export type HirKindAnchorVariant = {
226
+ '@type': 'struct'
227
+ '@name': 'regex_syntax::hir::HirKind'
228
+ '@variant': 'Anchor'
229
+ '@values': [Anchor]
230
+ }
231
+
232
+ export type HirKindWordBoundaryVariant = {
233
+ '@type': 'struct'
234
+ '@name': 'regex_syntax::hir::HirKind'
235
+ '@variant': 'WordBoundary'
236
+ '@values': [WordBoundary]
237
+ }
238
+
239
+ export type HirKindRepetitionVariant = {
240
+ '@type': 'struct'
241
+ '@name': 'regex_syntax::hir::HirKind'
242
+ '@variant': 'Repetition'
243
+ '@values': [Repetition]
244
+ }
245
+
246
+ export type HirKindGroupVariant = {
247
+ '@type': 'struct'
248
+ '@name': 'regex_syntax::hir::HirKind'
249
+ '@variant': 'Group'
250
+ '@values': [Group]
251
+ }
252
+
253
+ export type HirKindConcatVariant = {
254
+ '@type': 'struct'
255
+ '@name': 'regex_syntax::hir::HirKind'
256
+ '@variant': 'Concat'
257
+ '@values': [Hir[]]
258
+ }
259
+
260
+ export type HirKindAlternationVariant = {
261
+ '@type': 'struct'
262
+ '@name': 'regex_syntax::hir::HirKind'
263
+ '@variant': 'Alternation'
264
+ '@values': [Hir[]]
265
+ }
266
+
267
+
268
+
273
269
  export type RepetitionRange =
274
270
  | RepetitionRangeExactlyVariant
275
271
  | RepetitionRangeAtLeastVariant
@@ -343,170 +339,118 @@ export type Match = {
343
339
 
344
340
 
345
341
  /**
346
- * A compiled regular expression for matching Unicode strings.
347
- * @see https://docs.rs/regex/latest/regex/
348
- */
342
+ * A compiled regular expression for matching Unicode strings.
343
+ * @see https://docs.rs/regex/latest/regex/
344
+ */
349
345
  export class RRegex {
350
346
  free(): void;
351
- /**
352
- * Compiles a regular expression. Once compiled, it can be used repeatedly to search, split or replace text in a string.
353
- * If an invalid expression is given, then an error is returned.
354
- * @param {string} re
355
- */
356
- constructor(re: string);
357
- /**
358
- * Returns true if and only if there is a match for the regex in the string given.
359
- * 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.
360
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match
361
- * @param {string} text
362
- * @returns {boolean}
363
- */
364
- isMatch(text: string): boolean;
365
- /**
366
- * Returns the same as is_match, but starts the search at the given offset.
367
- * 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`.
368
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at
369
- * @param {string} text
370
- * @param {number} start
371
- * @returns {boolean}
372
- */
347
+ /**
348
+ * Returns the same as is_match, but starts the search at the given offset.
349
+ * 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`.
350
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at
351
+ */
373
352
  isMatchAt(text: string, start: number): boolean;
374
- /**
375
- * Returns the start and end byte range of the leftmost-first match in `text`. If no match exists, then `undefined` is returned.
376
- * 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`.
377
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find
378
- * @param {string} text
379
- * @returns {any}
380
- */
381
- find(text: string): Match | undefined;
382
- /**
383
- * Returns the same as find, but starts the search at the given offset.
384
- * 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`.
385
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at
386
- * @param {string} text
387
- * @param {number} start
388
- * @returns {any}
389
- */
390
- findAt(text: string, start: number): Match | undefined;
391
- /**
392
- * Returns an array for each successive non-overlapping match in text, returning the start and end byte indices with respect to text.
393
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter
394
- * @param {string} text
395
- * @returns {any}
396
- */
397
- findAll(text: string): Match[];
398
- /**
399
- * Replaces the leftmost-first match with the replacement provided.
400
- * 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.
401
- * If no match is found, then a copy of the string is returned unchanged.
402
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace
403
- * @param {string} text
404
- * @param {string} rep
405
- * @returns {string}
406
- */
407
- replace(text: string, rep: string): string;
408
- /**
409
- * Replaces at most `limit` non-overlapping matches in `text` with the replacement provided. If `limit` is 0, then all non-overlapping matches are replaced.
410
- * See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
411
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen
412
- * @param {string} text
413
- * @param {number} limit
414
- * @param {string} rep
415
- * @returns {string}
416
- */
417
- replacen(text: string, limit: number, rep: string): string;
418
- /**
419
- * Replaces all non-overlapping matches in `text` with the replacement provided. This is the same as calling `replacen` with `limit` set to `0`.
420
- * See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
421
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all
422
- * @param {string} text
423
- * @param {string} rep
424
- * @returns {string}
425
- */
353
+ /**
354
+ * Replaces all non-overlapping matches in `text` with the replacement provided. This is the same as calling `replacen` with `limit` set to `0`.
355
+ * See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
356
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all
357
+ */
426
358
  replaceAll(text: string, rep: string): string;
427
- /**
428
- * 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.
429
- * This method will not copy the text given.
430
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.split
431
- * @param {string} text
432
- * @returns {any}
433
- */
434
- split(text: string): string[];
435
- /**
436
- * 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.
437
- * This method will not copy the text given.
438
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn
439
- * @param {string} text
440
- * @param {number} limit
441
- * @returns {any}
442
- */
443
- splitn(text: string, limit: number): string[];
444
- /**
445
- * Returns the end location of a match in the text given.
446
- * 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.
447
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match
448
- * @param {string} text
449
- * @returns {number | undefined}
450
- */
359
+ /**
360
+ * Returns the end location of a match in the text given.
361
+ * 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.
362
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match
363
+ */
451
364
  shortestMatch(text: string): number | undefined;
452
- /**
453
- * Returns the same as shortest_match, but starts the search at the given offset.
454
- * 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`.
455
- * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at
456
- * @param {string} text
457
- * @param {number} limit
458
- * @returns {number | undefined}
459
- */
365
+ /**
366
+ * Returns the same as shortest_match, but starts the search at the given offset.
367
+ * 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`.
368
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at
369
+ */
460
370
  shortestMatchAt(text: string, limit: number): number | undefined;
461
- /**
462
- * Return the Regex syntax object
463
- * @returns {any}
464
- */
371
+ /**
372
+ * Compiles a regular expression. Once compiled, it can be used repeatedly to search, split or replace text in a string.
373
+ * If an invalid expression is given, then an error is returned.
374
+ */
375
+ constructor(re: string);
376
+ /**
377
+ * Returns the start and end byte range of the leftmost-first match in `text`. If no match exists, then `undefined` is returned.
378
+ * 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`.
379
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find
380
+ */
381
+ find(text: string): Match | undefined;
382
+ /**
383
+ * 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.
384
+ * This method will not copy the text given.
385
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.split
386
+ */
387
+ split(text: string): string[];
388
+ /**
389
+ * 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.
390
+ * This method will not copy the text given.
391
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn
392
+ */
393
+ splitn(text: string, limit: number): string[];
394
+ /**
395
+ * Return the Regex syntax object
396
+ */
465
397
  syntax(): Hir;
466
- /**
467
- * Returns a string representing the regular expression
468
- * @returns {string}
469
- */
398
+ /**
399
+ * Returns the same as find, but starts the search at the given offset.
400
+ * 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`.
401
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at
402
+ */
403
+ findAt(text: string, start: number): Match | undefined;
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
409
+ */
410
+ replace(text: string, rep: string): string;
411
+ /**
412
+ * Returns an array for each successive non-overlapping match in text, returning the start and end byte indices with respect to text.
413
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter
414
+ */
415
+ findAll(text: string): Match[];
416
+ /**
417
+ * Returns true if and only if there is a match for the regex in the string given.
418
+ * 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.
419
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match
420
+ */
421
+ isMatch(text: string): boolean;
422
+ /**
423
+ * Replaces at most `limit` non-overlapping matches in `text` with the replacement provided. If `limit` is 0, then all non-overlapping matches are replaced.
424
+ * See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
425
+ * @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen
426
+ */
427
+ replacen(text: string, limit: number, rep: string): string;
428
+ /**
429
+ * Returns a string representing the regular expression
430
+ */
470
431
  toString(): string;
471
432
  }
472
433
  /**
473
- * Match multiple (possibly overlapping) regular expressions in a single scan.
474
- * 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.
475
- * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
476
- */
434
+ * Match multiple (possibly overlapping) regular expressions in a single scan.
435
+ * 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.
436
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
437
+ */
477
438
  export class RRegexSet {
478
439
  free(): void;
479
- /**
480
- * Create a new regex set with the given regular expressions.
481
- * @param {Array<any>} list
482
- */
440
+ /**
441
+ * Create a new regex set with the given regular expressions.
442
+ */
483
443
  constructor(list: Array<any>);
484
- /**
485
- * Returns true if and only if one of the regexes in this set matches the text given.
486
- * 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.
487
- * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.is_match
488
- * @param {string} text
489
- * @returns {boolean}
490
- */
491
- isMatch(text: string): boolean;
492
- /**
493
- * Returns the set of regular expressions that match in the given text.
494
- * 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.
495
- * the set can also be used to iterate over the matched indices.
496
- * @param {string} text
497
- * @returns {any}
498
- */
444
+ /**
445
+ * Returns the set of regular expressions that match in the given text.
446
+ * 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.
447
+ * the set can also be used to iterate over the matched indices.
448
+ */
499
449
  matches(text: string): any;
500
- }
501
-
502
- export const metadata: {
503
- "name": "rregex",
504
- "description": "Rust Regex binding for Javascript",
505
- "authors": [
506
- "Fede Ramirez <i@2fd.me>"
507
- ],
508
- "homepage": "https://2fd.github.io/rregex",
509
- "repository": "https://github.com/2fd/rregex",
510
- "regex": "1.2.1",
511
- "regex-syntax": "0.6.25"
450
+ /**
451
+ * Returns true if and only if one of the regexes in this set matches the text given.
452
+ * 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.
453
+ * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.is_match
454
+ */
455
+ isMatch(text: string): boolean;
512
456
  }