rregex 1.13.3 → 2.0.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.
@@ -6,7 +6,7 @@
6
6
  * The string returned may be safely used as a literal in a regular
7
7
  * expression.
8
8
  */
9
- export function escape(text: string): string;
9
+ export declare function escape(text: string): string;
10
10
  /**
11
11
  * Represents a single match of a regex in a haystack.
12
12
  *
@@ -55,20 +55,18 @@ export function escape(text: string): string;
55
55
  * @see @see https://docs.rs/regex/latest/regex/
56
56
  */
57
57
  export type Match = {
58
- start: number
59
- end: number
60
- value: string
61
- }
62
-
58
+ start: number;
59
+ end: number;
60
+ value: string;
61
+ };
63
62
  /**
64
63
  * A high-level intermediate representation (HIR) for a regular expression.
65
64
  */
66
65
  export type Hir = {
67
- '@type': 'struct'
68
- '@name': 'regex_syntax::hir::Hir'
69
- kind: HirKind
70
- }
71
-
66
+ '@type': 'struct';
67
+ '@name': 'regex_syntax::hir::Hir';
68
+ kind: HirKind;
69
+ };
72
70
  /**
73
71
  * The underlying kind of an arbitrary `Hir` expression.
74
72
  *
@@ -78,35 +76,24 @@ export type Hir = {
78
76
  * new `Hir` values. The API intentionally does not expose any way of building an
79
77
  * `Hir` directly from an `HirKind`.
80
78
  */
81
- export type HirKind =
82
- | HirKindEmptyVariant
83
- | HirKindLiteralVariant
84
- | HirKindClassVariant
85
- | HirKindLookVariant
86
- | HirKindRepetitionVariant
87
- | HirKindCaptureVariant
88
- | HirKindConcatVariant
89
- | HirKindAlternationVariant
90
-
79
+ export type HirKind = HirKindEmptyVariant | HirKindLiteralVariant | HirKindClassVariant | HirKindLookVariant | HirKindRepetitionVariant | HirKindCaptureVariant | HirKindConcatVariant | HirKindAlternationVariant;
91
80
  /**
92
81
  * The empty regular expression, which matches everything, including the empty string.
93
82
  */
94
83
  export type HirKindEmptyVariant = {
95
- '@type': 'enum'
96
- '@name': 'regex_syntax::hir::HirKind'
97
- '@variant': 'Empty'
98
- }
99
-
84
+ '@type': 'enum';
85
+ '@name': 'regex_syntax::hir::HirKind';
86
+ '@variant': 'Empty';
87
+ };
100
88
  /**
101
89
  * A literal string that matches exactly these bytes.
102
90
  */
103
91
  export type HirKindLiteralVariant = {
104
- '@type': 'enum'
105
- '@name': 'regex_syntax::hir::HirKind'
106
- '@variant': 'Literal'
107
- '@values': [Literal]
108
- }
109
-
92
+ '@type': 'enum';
93
+ '@name': 'regex_syntax::hir::HirKind';
94
+ '@variant': 'Literal';
95
+ '@values': [Literal];
96
+ };
110
97
  /**
111
98
  * A single character class that matches any of the characters in the class.
112
99
  * A class can either consist of Unicode scalar values as characters, or it can
@@ -115,42 +102,38 @@ export type HirKindLiteralVariant = {
115
102
  * A class may be empty. In which case, it matches nothing.
116
103
  */
117
104
  export type HirKindClassVariant = {
118
- '@type': 'enum'
119
- '@name': 'regex_syntax::hir::HirKind'
120
- '@variant': 'Class'
121
- '@values': [Class]
122
- }
123
-
105
+ '@type': 'enum';
106
+ '@name': 'regex_syntax::hir::HirKind';
107
+ '@variant': 'Class';
108
+ '@values': [Class];
109
+ };
124
110
  /**
125
111
  * A look-around assertion. A look-around match always has zero length.
126
112
  */
127
113
  export type HirKindLookVariant = {
128
- '@type': 'enum'
129
- '@name': 'regex_syntax::hir::HirKind'
130
- '@variant': 'Look'
131
- '@values': [Look]
132
- }
133
-
114
+ '@type': 'enum';
115
+ '@name': 'regex_syntax::hir::HirKind';
116
+ '@variant': 'Look';
117
+ '@values': [Look];
118
+ };
134
119
  /**
135
120
  * A repetition operation applied to a sub-expression.
136
121
  */
137
122
  export type HirKindRepetitionVariant = {
138
- '@type': 'enum'
139
- '@name': 'regex_syntax::hir::HirKind'
140
- '@variant': 'Repetition'
141
- '@values': [Repetition]
142
- }
143
-
123
+ '@type': 'enum';
124
+ '@name': 'regex_syntax::hir::HirKind';
125
+ '@variant': 'Repetition';
126
+ '@values': [Repetition];
127
+ };
144
128
  /**
145
129
  * A capturing group, which contains a sub-expression.
146
130
  */
147
131
  export type HirKindCaptureVariant = {
148
- '@type': 'enum'
149
- '@name': 'regex_syntax::hir::HirKind'
150
- '@variant': 'Capture'
151
- '@values': [Capture]
152
- }
153
-
132
+ '@type': 'enum';
133
+ '@name': 'regex_syntax::hir::HirKind';
134
+ '@variant': 'Capture';
135
+ '@values': [Capture];
136
+ };
154
137
  /**
155
138
  * A concatenation of expressions.
156
139
  *
@@ -161,12 +144,11 @@ export type HirKindCaptureVariant = {
161
144
  * least two sub-expressions.
162
145
  */
163
146
  export type HirKindConcatVariant = {
164
- '@type': 'enum'
165
- '@name': 'regex_syntax::hir::HirKind'
166
- '@variant': 'Concat'
167
- '@values': [Hir[]]
168
- }
169
-
147
+ '@type': 'enum';
148
+ '@name': 'regex_syntax::hir::HirKind';
149
+ '@variant': 'Concat';
150
+ '@values': [Hir[]];
151
+ };
170
152
  /**
171
153
  * An alternation of expressions.
172
154
  *
@@ -177,12 +159,11 @@ export type HirKindConcatVariant = {
177
159
  * least two sub-expressions.
178
160
  */
179
161
  export type HirKindAlternationVariant = {
180
- '@type': 'enum'
181
- '@name': 'regex_syntax::hir::HirKind'
182
- '@variant': 'Alternation'
183
- '@values': [Hir[]]
184
- }
185
-
162
+ '@type': 'enum';
163
+ '@name': 'regex_syntax::hir::HirKind';
164
+ '@variant': 'Alternation';
165
+ '@values': [Hir[]];
166
+ };
186
167
  /**
187
168
  * The high-level intermediate representation of a literal.
188
169
  *
@@ -192,11 +173,10 @@ export type HirKindAlternationVariant = {
192
173
  * with `HirKind::Empty`.
193
174
  */
194
175
  export type Literal = {
195
- '@type': 'struct'
196
- '@name': 'regex_syntax::hir::Literal'
197
- '@values': [Uint8Array]
198
- }
199
-
176
+ '@type': 'struct';
177
+ '@name': 'regex_syntax::hir::Literal';
178
+ '@values': [Uint8Array];
179
+ };
200
180
  /**
201
181
  * The high-level intermediate representation of a character class.
202
182
  *
@@ -213,41 +193,34 @@ export type Literal = {
213
193
  * impacts the semantics of case insensitive matching. For example, `(?i)k` and
214
194
  * `(?i-u)k` will not match the same set of strings.
215
195
  */
216
- export type Class =
217
- | ClassUnicodeVariant
218
- | ClassByteVariant
219
-
196
+ export type Class = ClassUnicodeVariant | ClassByteVariant;
220
197
  /**
221
198
  * A set of characters represented by Unicode scalar values.
222
199
  */
223
200
  export type ClassUnicodeVariant = {
224
- '@type': 'enum'
225
- '@name': 'regex_syntax::hir::Class'
226
- '@variant': 'Unicode'
227
- '@values': [ClassUnicode]
228
- }
229
-
201
+ '@type': 'enum';
202
+ '@name': 'regex_syntax::hir::Class';
203
+ '@variant': 'Unicode';
204
+ '@values': [ClassUnicode];
205
+ };
230
206
  /**
231
207
  * A set of characters represented by arbitrary bytes (one byte per character).
232
208
  */
233
209
  export type ClassByteVariant = {
234
- '@type': 'enum'
235
- '@name': 'regex_syntax::hir::Class'
236
- '@variant': 'Bytes'
237
- '@values': [ClassBytes]
238
- }
239
-
210
+ '@type': 'enum';
211
+ '@name': 'regex_syntax::hir::Class';
212
+ '@variant': 'Bytes';
213
+ '@values': [ClassBytes];
214
+ };
240
215
  /**
241
216
  * A set of characters represented by Unicode scalar values.
242
217
  */
243
218
  export type ClassUnicode = {
244
- '@type': 'struct'
245
- '@name': 'regex_syntax::hir::ClassUnicode'
246
-
219
+ '@type': 'struct';
220
+ '@name': 'regex_syntax::hir::ClassUnicode';
247
221
  /** The underlying ranges as a slice. */
248
- ranges: ClassUnicodeRange[]
249
- }
250
-
222
+ ranges: ClassUnicodeRange[];
223
+ };
251
224
  /**
252
225
  * A single range of characters represented by Unicode scalar values.
253
226
  *
@@ -255,41 +228,35 @@ export type ClassUnicode = {
255
228
  * the range.
256
229
  */
257
230
  export type ClassUnicodeRange = {
258
- '@type': 'struct'
259
- '@name': 'regex_syntax::hir::ClassUnicodeRange'
260
-
231
+ '@type': 'struct';
232
+ '@name': 'regex_syntax::hir::ClassUnicodeRange';
261
233
  /**
262
234
  * Return the start of this range.
263
235
  *
264
236
  * The start of a range is always less than or equal to the end of the range.
265
237
  */
266
- start: string
267
-
238
+ start: string;
268
239
  /**
269
240
  * Return the end of this range.
270
241
  *
271
242
  * The end of a range is always greater than or equal to the start of the range.
272
243
  */
273
- end: string
274
-
244
+ end: string;
275
245
  /**
276
246
  * The number of codepoints in this range.
277
247
  */
278
- len: number
279
- }
280
-
248
+ len: number;
249
+ };
281
250
  /**
282
251
  * A set of characters represented by arbitrary bytes (where one byte corresponds
283
252
  * to one character).
284
253
  */
285
254
  export type ClassBytes = {
286
- '@type': 'struct'
287
- '@name': 'regex_syntax::hir::ClassBytes'
288
-
255
+ '@type': 'struct';
256
+ '@name': 'regex_syntax::hir::ClassBytes';
289
257
  /** The underlying ranges as a slice. */
290
- ranges: ClassBytesRange[]
291
- }
292
-
258
+ ranges: ClassBytesRange[];
259
+ };
293
260
  /**
294
261
  * A single range of characters represented by arbitrary bytes.
295
262
  *
@@ -297,96 +264,69 @@ export type ClassBytes = {
297
264
  * the range.
298
265
  */
299
266
  export type ClassBytesRange = {
300
- '@type': 'struct'
301
- '@name': 'regex_syntax::hir::ClassBytesRange'
302
-
267
+ '@type': 'struct';
268
+ '@name': 'regex_syntax::hir::ClassBytesRange';
303
269
  /**
304
270
  * The start of this range.
305
271
  *
306
272
  * The start of a range is always less than or equal to the end of the range.
307
273
  */
308
- start: number
309
-
274
+ start: number;
310
275
  /**
311
276
  * The end of this range.
312
277
  *
313
278
  * The end of a range is always greater than or equal to the start of the range.
314
279
  */
315
- end: number
316
-
280
+ end: number;
317
281
  /**
318
282
  * The number of bytes in this range.
319
283
  */
320
- len: number
321
- }
322
-
323
- /**
284
+ len: number;
285
+ };
286
+ /**
324
287
  * The high-level intermediate representation for a look-around assertion.
325
288
  *
326
289
  * An assertion match is always zero-length. Also called an “empty match.”
327
290
  */
328
- export type Look =
329
- | LookStartVariant
330
- | LookEndVariant
331
- | LookStartLFVariant
332
- | LookEndLFVariant
333
- | LookStartCRLFVariant
334
- | LookEndCRLFVariant
335
- | LookWordAsciiVariant
336
- | LookWordAsciiNegateVariant
337
- | LookWordUnicodeVariant
338
- | LookWordUnicodeNegateVariant
339
- | LookWordStartAsciiVariant
340
- | LookWordEndAsciiVariant
341
- | LookWordStartUnicodeVariant
342
- | LookWordEndUnicodeVariant
343
- | LookWordStartHalfAsciiVariant
344
- | LookWordEndHalfAsciiVariant
345
- | LookWordStartHalfUnicodeVariant
346
- | LookWordEndHalfUnicodeVariant
347
-
291
+ export type Look = LookStartVariant | LookEndVariant | LookStartLFVariant | LookEndLFVariant | LookStartCRLFVariant | LookEndCRLFVariant | LookWordAsciiVariant | LookWordAsciiNegateVariant | LookWordUnicodeVariant | LookWordUnicodeNegateVariant | LookWordStartAsciiVariant | LookWordEndAsciiVariant | LookWordStartUnicodeVariant | LookWordEndUnicodeVariant | LookWordStartHalfAsciiVariant | LookWordEndHalfAsciiVariant | LookWordStartHalfUnicodeVariant | LookWordEndHalfUnicodeVariant;
348
292
  /**
349
293
  * Match the beginning of text. Specifically, this matches at the starting
350
294
  * position of the input.
351
295
  */
352
296
  export type LookStartVariant = {
353
- '@type': 'enum'
354
- '@name': 'regex_syntax::hir:Look'
355
- '@variant': 'Start'
356
- }
357
-
297
+ '@type': 'enum';
298
+ '@name': 'regex_syntax::hir:Look';
299
+ '@variant': 'Start';
300
+ };
358
301
  /**
359
302
  * Match the end of text. Specifically, this matches at the ending position of
360
303
  * the input.
361
304
  */
362
305
  export type LookEndVariant = {
363
- '@type': 'enum'
364
- '@name': 'regex_syntax::hir:Look'
365
- '@variant': 'End'
366
- }
367
-
306
+ '@type': 'enum';
307
+ '@name': 'regex_syntax::hir:Look';
308
+ '@variant': 'End';
309
+ };
368
310
  /**
369
311
  * Match the beginning of a line or the beginning of text. Specifically, this
370
312
  * matches at the starting position of the input, or at the position immediately
371
313
  * following a `\n` character.
372
314
  */
373
315
  export type LookStartLFVariant = {
374
- '@type': 'enum'
375
- '@name': 'regex_syntax::hir:Look'
376
- '@variant': 'StartLF'
377
- }
378
-
316
+ '@type': 'enum';
317
+ '@name': 'regex_syntax::hir:Look';
318
+ '@variant': 'StartLF';
319
+ };
379
320
  /**
380
321
  * Match the end of a line or the end of text. Specifically, this matches at the
381
322
  * end position of the input, or at the position immediately preceding a `\n`
382
323
  * character.
383
324
  */
384
325
  export type LookEndLFVariant = {
385
- '@type': 'enum'
386
- '@name': 'regex_syntax::hir:Look'
387
- '@variant': 'EndLF'
388
- }
389
-
326
+ '@type': 'enum';
327
+ '@name': 'regex_syntax::hir:Look';
328
+ '@variant': 'EndLF';
329
+ };
390
330
  /**
391
331
  * Match the beginning of a line or the beginning of text. Specifically, this
392
332
  * matches at the starting position of the input, or at the position immediately
@@ -394,62 +334,56 @@ export type LookEndLFVariant = {
394
334
  * follows.
395
335
  */
396
336
  export type LookStartCRLFVariant = {
397
- '@type': 'enum'
398
- '@name': 'regex_syntax::hir:Look'
399
- '@variant': 'StartCRLF'
400
- }
401
-
337
+ '@type': 'enum';
338
+ '@name': 'regex_syntax::hir:Look';
339
+ '@variant': 'StartCRLF';
340
+ };
402
341
  /**
403
342
  * Match the end of a line or the end of text. Specifically, this matches at the
404
343
  * end position of the input, or at the position immediately preceding a `\r` or
405
344
  * `\n` character, but never before a `\n` when a `\r` precedes it.
406
345
  */
407
346
  export type LookEndCRLFVariant = {
408
- '@type': 'enum'
409
- '@name': 'regex_syntax::hir:Look'
410
- '@variant': 'EndCRLF'
411
- }
412
-
347
+ '@type': 'enum';
348
+ '@name': 'regex_syntax::hir:Look';
349
+ '@variant': 'EndCRLF';
350
+ };
413
351
  /**
414
352
  * Match an ASCII-only word boundary. That is, this matches a position where the
415
353
  * left adjacent character and right adjacent character correspond to a word and
416
354
  * non-word or a non-word and word character.
417
355
  */
418
356
  export type LookWordAsciiVariant = {
419
- '@type': 'enum'
420
- '@name': 'regex_syntax::hir:Look'
421
- '@variant': 'WordAscii'
422
- }
423
-
357
+ '@type': 'enum';
358
+ '@name': 'regex_syntax::hir:Look';
359
+ '@variant': 'WordAscii';
360
+ };
424
361
  /**
425
362
  * Match an ASCII-only negation of a word boundary.
426
363
  */
427
364
  export type LookWordAsciiNegateVariant = {
428
- '@type': 'enum'
429
- '@name': 'regex_syntax::hir:Look'
430
- '@variant': 'WordAsciiNegate'
431
- }
432
-
365
+ '@type': 'enum';
366
+ '@name': 'regex_syntax::hir:Look';
367
+ '@variant': 'WordAsciiNegate';
368
+ };
433
369
  /**
434
370
  * Match a Unicode-aware word boundary. That is, this matches a position where
435
371
  * the left adjacent character and right adjacent character correspond to a word
436
372
  * and non-word or a non-word and word character.
437
373
  */
438
374
  export type LookWordUnicodeVariant = {
439
- '@type': 'enum'
440
- '@name': 'regex_syntax::hir:Look'
441
- '@variant': 'WordUnicode'
442
- }
443
-
375
+ '@type': 'enum';
376
+ '@name': 'regex_syntax::hir:Look';
377
+ '@variant': 'WordUnicode';
378
+ };
444
379
  /**
445
380
  * Match a Unicode-aware negation of a word boundary.
446
381
  */
447
382
  export type LookWordUnicodeNegateVariant = {
448
- '@type': 'enum'
449
- '@name': 'regex_syntax::hir:Look'
450
- '@variant': 'WordUnicodeNegate'
451
- }
452
-
383
+ '@type': 'enum';
384
+ '@name': 'regex_syntax::hir:Look';
385
+ '@variant': 'WordUnicodeNegate';
386
+ };
453
387
  /**
454
388
  * Match the start of an ASCII-only word boundary. That is, this matches a
455
389
  * position at either the beginning of the haystack or where the previous
@@ -457,97 +391,88 @@ export type LookWordUnicodeNegateVariant = {
457
391
  * character.
458
392
  */
459
393
  export type LookWordStartAsciiVariant = {
460
- '@type': 'enum'
461
- '@name': 'regex_syntax::hir:Look'
462
- '@variant': 'WordStartAscii'
463
- }
464
-
394
+ '@type': 'enum';
395
+ '@name': 'regex_syntax::hir:Look';
396
+ '@variant': 'WordStartAscii';
397
+ };
465
398
  /**
466
399
  * Match the end of an ASCII-only word boundary. That is, this matches a
467
400
  * position at either the end of the haystack orwhere the previous character is
468
401
  * a word character and the following character is not a word character.
469
402
  */
470
403
  export type LookWordEndAsciiVariant = {
471
- '@type': 'enum'
472
- '@name': 'regex_syntax::hir:Look'
473
- '@variant': 'WordEndAscii'
474
- }
475
-
404
+ '@type': 'enum';
405
+ '@name': 'regex_syntax::hir:Look';
406
+ '@variant': 'WordEndAscii';
407
+ };
476
408
  /**
477
409
  * Match the start of a Unicode word boundary. That is, this matches a position
478
410
  * at either the beginning of the haystack or where the previous character is
479
411
  * not a word character and the following character is a word character.
480
412
  */
481
413
  export type LookWordStartUnicodeVariant = {
482
- '@type': 'enum'
483
- '@name': 'regex_syntax::hir:Look'
484
- '@variant': 'WordStartUnicode'
485
- }
486
-
414
+ '@type': 'enum';
415
+ '@name': 'regex_syntax::hir:Look';
416
+ '@variant': 'WordStartUnicode';
417
+ };
487
418
  /**
488
419
  * Match the end of a Unicode word boundary. That is, this matches a position at
489
420
  * either the end of the haystack or where the previous character is a word
490
421
  * character and the following character is not a word character.
491
422
  */
492
423
  export type LookWordEndUnicodeVariant = {
493
- '@type': 'enum'
494
- '@name': 'regex_syntax::hir:Look'
495
- '@variant': 'WordEndUnicode'
496
- }
497
-
424
+ '@type': 'enum';
425
+ '@name': 'regex_syntax::hir:Look';
426
+ '@variant': 'WordEndUnicode';
427
+ };
498
428
  /**
499
429
  * Match the start half of an ASCII-only word boundary. That is, this matches a
500
430
  * position at either the beginning of the haystack or where the previous
501
431
  * character is not a word character.
502
432
  */
503
433
  export type LookWordStartHalfAsciiVariant = {
504
- '@type': 'enum'
505
- '@name': 'regex_syntax::hir::Look',
506
- '@variant': 'WordStartHalfAscii'
507
- }
508
-
434
+ '@type': 'enum';
435
+ '@name': 'regex_syntax::hir::Look';
436
+ '@variant': 'WordStartHalfAscii';
437
+ };
509
438
  /**
510
439
  * Match the end half of an ASCII-only word boundary. That is, this matches a
511
440
  * position at either the end of the haystack or where the following character
512
441
  * is not a word character.
513
442
  */
514
443
  export type LookWordEndHalfAsciiVariant = {
515
- '@type': 'enum'
516
- '@name': 'regex_syntax::hir::Look',
517
- '@variant': 'WordEndHalfAscii'
518
- }
519
-
444
+ '@type': 'enum';
445
+ '@name': 'regex_syntax::hir::Look';
446
+ '@variant': 'WordEndHalfAscii';
447
+ };
520
448
  /**
521
449
  * Match the start half of a Unicode word boundary. That is, this matches a
522
450
  * position at either the beginning of the haystack or where the previous
523
451
  * character is not a word character.
524
452
  */
525
453
  export type LookWordStartHalfUnicodeVariant = {
526
- '@type': 'enum'
527
- '@name': 'regex_syntax::hir::Look',
528
- '@variant': 'WordStartHalfUnicode'
529
- }
530
-
454
+ '@type': 'enum';
455
+ '@name': 'regex_syntax::hir::Look';
456
+ '@variant': 'WordStartHalfUnicode';
457
+ };
531
458
  /**
532
459
  * Match the end half of a Unicode word boundary. That is, this matches a
533
460
  * position at either the end of the haystack or where the following character
534
461
  * is not a word character.
535
462
  */
536
463
  export type LookWordEndHalfUnicodeVariant = {
537
- '@type': 'enum'
538
- '@name': 'regex_syntax::hir::Look',
539
- '@variant': 'WordEndHalfUnicode'
540
- }
541
-
464
+ '@type': 'enum';
465
+ '@name': 'regex_syntax::hir::Look';
466
+ '@variant': 'WordEndHalfUnicode';
467
+ };
542
468
  /**
543
469
  * The high-level intermediate representation of a repetition operator.
544
470
  *
545
471
  * A repetition operator permits the repetition of an arbitrary sub-expression
546
472
  */
547
473
  export type Repetition = {
548
- '@type': 'struct'
549
- '@name': 'regex_syntax::hir::Repetition'
550
-
474
+ '@type': 'struct';
475
+ '@name': 'regex_syntax::hir::Repetition';
551
476
  /**
552
477
  * The minimum range of the repetition.
553
478
  *
@@ -557,8 +482,7 @@ export type Repetition = {
557
482
  * When `min` is zero, this expression can match the empty string regardless
558
483
  * of what its sub-expression is.
559
484
  */
560
- min: number
561
-
485
+ min: number;
562
486
  /**
563
487
  * The maximum range of the repetition.
564
488
  *
@@ -566,8 +490,7 @@ export type Repetition = {
566
490
  * there is no upper bound. For something like `x{5}` where the min and max
567
491
  * are equivalent, `min` will be set to `5` and `max` will be set to `5`.
568
492
  */
569
- max?: number
570
-
493
+ max?: number;
571
494
  /**
572
495
  * Whether this repetition operator is greedy or not. A greedy operator will
573
496
  * match as much as it can. A non-greedy operator will match as little as it
@@ -577,14 +500,12 @@ export type Repetition = {
577
500
  * `?` suffix is used, e.g., `(expr)*` is greedy while `(expr)*?` is not.
578
501
  * However, this can be inverted via the `U` “ungreedy” flag.
579
502
  */
580
- greedy: boolean
581
-
503
+ greedy: boolean;
582
504
  /**
583
505
  * The expression being repeated.
584
506
  */
585
- sub: Hir
586
- }
587
-
507
+ sub: Hir;
508
+ };
588
509
  /**
589
510
  * Represents the capture groups for a single match.
590
511
  *
@@ -629,10 +550,9 @@ export type Repetition = {
629
550
  * ```
630
551
  */
631
552
  export type Captures = {
632
- get: Match[]
633
- name: Record<string, Match>
634
- }
635
-
553
+ get: Match[];
554
+ name: Record<string, Match>;
555
+ };
636
556
  /**
637
557
  * The high-level intermediate representation for a capturing group.
638
558
  *
@@ -644,19 +564,61 @@ export type Captures = {
644
564
  * recursive structure of the `Hir` itself.
645
565
  */
646
566
  export type Capture = {
647
- '@type': 'struct'
648
- '@name': 'regex_syntax::hir::Capture'
649
-
567
+ '@type': 'struct';
568
+ '@name': 'regex_syntax::hir::Capture';
650
569
  /** The capture index of the capture. */
651
- index: number
652
-
570
+ index: number;
653
571
  /** The name of the capture, if it exists. */
654
- name?: String
655
-
572
+ name?: String;
656
573
  /** The expression inside the capturing group, which may be empty. */
657
- sub: Hir
658
- }
659
-
574
+ sub: Hir;
575
+ };
576
+ /**
577
+ * Options to compile a `RRegex` or a `RRegexSet`. Every option is optional
578
+ * and only applies to the instance that receives it.
579
+ *
580
+ * # Example
581
+ *
582
+ * ```typescript
583
+ * import { RRegex } from "rregex"
584
+ *
585
+ * // Unicode classes make this pattern exceed the default 10 MiB size limit
586
+ * const re = new RRegex("\\w{200}\\s\\w{200}", { sizeLimit: 200 * 1024 * 1024 })
587
+ * ```
588
+ *
589
+ * @see https://docs.rs/regex/latest/regex/struct.RegexBuilder.html
590
+ */
591
+ export type RRegexOptions = {
592
+ /**
593
+ * The approximate size limit, in bytes, of the compiled regular expression.
594
+ * If the compiled regular expression is bigger, the constructor throws.
595
+ *
596
+ * Increase it only for patterns that need it: the compiled program uses
597
+ * WebAssembly memory, which does not shrink after the instance is freed.
598
+ *
599
+ * @default 10485760 (10 MiB)
600
+ * @see https://docs.rs/regex/latest/regex/struct.RegexBuilder.html#method.size_limit
601
+ */
602
+ sizeLimit?: number;
603
+ /**
604
+ * The approximate capacity, in bytes, of the cache of transitions used by
605
+ * the lazy DFA. A bigger cache can make searches on big patterns faster.
606
+ * If the cache is too small, the search uses a slower engine, it does not
607
+ * throw.
608
+ *
609
+ * @default 2097152 (2 MiB)
610
+ * @see https://docs.rs/regex/latest/regex/struct.RegexBuilder.html#method.dfa_size_limit
611
+ */
612
+ dfaSizeLimit?: number;
613
+ /**
614
+ * The nesting limit of the parser. If the pattern has more nested groups,
615
+ * classes or repetitions, the constructor throws.
616
+ *
617
+ * @default 250
618
+ * @see https://docs.rs/regex/latest/regex/struct.RegexBuilder.html#method.nest_limit
619
+ */
620
+ nestLimit?: number;
621
+ };
660
622
  /**
661
623
  * A compiled regular expression for matching Unicode strings.
662
624
  *
@@ -698,7 +660,7 @@ export type Capture = {
698
660
  *
699
661
  * @see https://docs.rs/regex/latest/regex/
700
662
  */
701
- export class RRegex {
663
+ export declare class RRegex {
702
664
  free(): void;
703
665
  /**
704
666
  * Returns the same as is_match, but starts the search at the given offset.
@@ -850,8 +812,9 @@ export class RRegex {
850
812
  * to search, split or replace text in a string.
851
813
  *
852
814
  * If an invalid expression is given, then an error is returned.
815
+ * Options only apply to this instance, see `RRegexOptions`.
853
816
  */
854
- constructor(re: string);
817
+ constructor(re: string, options?: RRegexOptions | null);
855
818
  /**
856
819
  * Returns the start and end byte range of the leftmost-first match in
857
820
  * `text`. If no match exists, then `undefined` is returned.
@@ -1150,13 +1113,14 @@ export class RRegex {
1150
1113
  *
1151
1114
  * @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
1152
1115
  */
1153
- export class RRegexSet {
1116
+ export declare class RRegexSet {
1154
1117
  free(): void;
1155
1118
  /**
1156
1119
  * Create a new regex set with the given regular expressions.
1157
1120
  *
1158
- * This takes an of strings, if any item in the list is not a valid regular
1159
- * expressions, then an error is returned.
1121
+ * This takes an array of strings, if any item in the list is not a valid regular
1122
+ * expression, then an error is returned. Options only apply to this
1123
+ * instance, see `RRegexOptions`.
1160
1124
  *
1161
1125
  * # Example
1162
1126
  *
@@ -1169,7 +1133,7 @@ export class RRegexSet {
1169
1133
  * expect(set.is_match("foo")).toBe(true)
1170
1134
  * ```
1171
1135
  */
1172
- constructor(list: Array<any>);
1136
+ constructor(list: string[], options?: RRegexOptions | null);
1173
1137
  /**
1174
1138
  * Returns the set of regular expressions that match in the given text.
1175
1139
  *
@@ -1242,3 +1206,82 @@ export class RRegexSet {
1242
1206
  */
1243
1207
  isMatch(text: string): boolean;
1244
1208
  }
1209
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
1210
+ export interface InitOutput {
1211
+ readonly memory: WebAssembly.Memory;
1212
+ readonly __wbg_rregex_free: (a: number, b: number) => void;
1213
+ readonly rregex_captureNames: (a: number) => [number, number];
1214
+ readonly rregex_captures: (a: number, b: number, c: number) => [number, number, number];
1215
+ readonly rregex_capturesAll: (a: number, b: number, c: number) => [number, number, number];
1216
+ readonly rregex_capturesLength: (a: number) => number;
1217
+ readonly rregex_find: (a: number, b: number, c: number) => [number, number, number];
1218
+ readonly rregex_findAll: (a: number, b: number, c: number) => [number, number, number];
1219
+ readonly rregex_findAt: (a: number, b: number, c: number, d: number) => [number, number, number];
1220
+ readonly rregex_isMatch: (a: number, b: number, c: number) => number;
1221
+ readonly rregex_isMatchAt: (a: number, b: number, c: number, d: number) => number;
1222
+ readonly rregex_new: (a: number, b: number, c: number) => [number, number, number];
1223
+ readonly rregex_replace: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1224
+ readonly rregex_replaceAll: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1225
+ readonly rregex_replacen: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1226
+ readonly rregex_shortestMatch: (a: number, b: number, c: number) => number;
1227
+ readonly rregex_shortestMatchAt: (a: number, b: number, c: number, d: number) => number;
1228
+ readonly rregex_split: (a: number, b: number, c: number) => [number, number];
1229
+ readonly rregex_splitn: (a: number, b: number, c: number, d: number) => [number, number];
1230
+ readonly rregex_syntax: (a: number) => [number, number, number];
1231
+ readonly rregex_toString: (a: number) => [number, number];
1232
+ readonly __wbg_rregexset_free: (a: number, b: number) => void;
1233
+ readonly rregexset_isMatch: (a: number, b: number, c: number) => number;
1234
+ readonly rregexset_matches: (a: number, b: number, c: number) => [number, number];
1235
+ readonly rregexset_new: (a: any, b: number) => [number, number, number];
1236
+ readonly escape: (a: number, b: number) => [number, number];
1237
+ readonly __wbindgen_exn_store: (a: number) => void;
1238
+ readonly __externref_table_alloc: () => number;
1239
+ readonly __wbindgen_export_2: WebAssembly.Table;
1240
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
1241
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
1242
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
1243
+ readonly __externref_table_dealloc: (a: number) => void;
1244
+ readonly __externref_drop_slice: (a: number, b: number) => void;
1245
+ readonly __wbindgen_start: () => void;
1246
+ }
1247
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
1248
+ /** Build metadata */
1249
+ export declare const metadata: {
1250
+ readonly name: "rregex";
1251
+ readonly description: "Rust Regex binding for Javascript";
1252
+ readonly authors: readonly ["Fede Ramirez <i@2fd.me>"];
1253
+ readonly homepage: "http://rregex.dev";
1254
+ readonly repository: "https://github.com/2fd/rregex";
1255
+ readonly regex: "1.13.1";
1256
+ readonly "regex-syntax": "0.8.11";
1257
+ };
1258
+ export interface InitOptions {
1259
+ /** Bytes, a compiled `WebAssembly.Module`, or a `Response`, URL or path to fetch. */
1260
+ module_or_path: InitInput | Promise<InitInput>;
1261
+ }
1262
+ export interface InitSyncOptions {
1263
+ /** Bytes or a compiled `WebAssembly.Module`. */
1264
+ module: SyncInitInput;
1265
+ }
1266
+ /**
1267
+ * The raw exports of the WebAssembly instance (`memory`, allocator, bindings),
1268
+ * set by {@link init} and {@link initSync}. For tests and debugging only: it
1269
+ * is not part of the public API and can change in any release.
1270
+ *
1271
+ * @internal
1272
+ */
1273
+ export declare let __wasm: InitOutput | undefined;
1274
+ /** Returns `true` after the WebAssembly module has been instantiated. */
1275
+ export declare function isInitialized(): boolean;
1276
+ /**
1277
+ * Instantiates the WebAssembly module synchronously. Calls after the first
1278
+ * successful call have no effect.
1279
+ *
1280
+ * @param options - The module, or (deprecated) the module passed directly.
1281
+ */
1282
+ export declare function initSync(options: InitSyncOptions | SyncInitInput): void;
1283
+ /**
1284
+ * Instantiates the WebAssembly module asynchronously. Calls after the first
1285
+ * successful call have no effect.
1286
+ */
1287
+ export declare function init(options: InitOptions): Promise<void>;