re2js 2.8.6 → 2.8.7

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/build/index.d.ts CHANGED
@@ -1,119 +1,15 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
- declare class DFA {
4
- static MAX_CACHE_CLEARS: number;
5
- static STATE_MEMORY_ESTIMATE: number;
6
- constructor(prog: any, maxMem?: number);
7
- prog: any;
8
- stateCache: Map<any, any>;
9
- stateCount: number;
10
- startState: any;
11
- stateLimit: number;
12
- cacheClears: number;
13
- failed: boolean;
14
- clock: number;
15
- computeClosure(pcs: any): {
16
- pcs: Int32Array<ArrayBuffer>;
17
- isMatch: boolean;
18
- matchIDs: any[];
19
- };
20
- getState(pcs: any): any;
21
- evictCache(): void;
22
- step(state: any, charCode: any, anchor: any): any;
23
- match(input: any, pos: any, anchor: any): boolean;
24
- matchSet(input: any, pos: any, anchor: any): any[];
25
- }
26
- declare class Prog {
27
- inst: any[];
28
- start: number;
29
- numCap: number;
30
- lbStarts: any[];
31
- numLb: number;
32
- getInst(pc: any): any;
33
- numInst(): number;
34
- addInst(op: any): void;
35
- skipNop(pc: any): any;
36
- prefix(): (string | boolean)[];
37
- startCond(): number;
38
- patch(l: any, val: any): void;
39
- append(l1: any, l2: any): any;
40
- /**
41
- *
42
- * @returns {string}
43
- */
44
- toString(): string;
45
- }
46
- export class RE2Set {
47
- /** @type {number} */
48
- static UNANCHORED: number;
49
- /** @type {number} */
50
- static ANCHOR_START: number;
51
- /** @type {number} */
52
- static ANCHOR_BOTH: number;
53
- /**
54
- * Constructs a new RE2Set with the specified anchor mode and flags.
55
- * @param {number} [anchor=RE2Set.UNANCHORED] - The anchoring mode (e.g., RE2Set.UNANCHORED).
56
- * @param {number} [flags=0] - The public flags to apply to all patterns in the set.
57
- * @param {number} [maxMem=8388608] - The maximum memory in bytes to use for the DFA (default 8MB).
58
- */
59
- constructor(anchor?: number, flags?: number, maxMem?: number);
60
- anchor: number;
61
- jsFlags: number;
62
- maxMem: number;
63
- re2Flags: number;
64
- regexps: any[];
65
- prog: Prog;
66
- dfa: DFA;
67
- dummyRe2: {
68
- prog: Prog;
69
- cond: number;
70
- prefix: string;
71
- prefixRune: number;
72
- longest: boolean;
73
- };
74
- /**
75
- * Adds a new regular expression pattern to the set.
76
- * Patterns cannot be added after the set has been compiled.
77
- * @param {string} pattern - The regular expression pattern to add.
78
- * @returns {number} The integer index assigned to the added pattern.
79
- * @throws {RE2JSCompileException} If patterns are added after compilation.
80
- */
81
- add(pattern: string): number;
82
- /**
83
- * Compiles the added patterns into a single state machine.
84
- * This is automatically called on the first match if not called explicitly.
85
- * @returns {void}
86
- */
87
- compile(): void;
88
- /**
89
- * Matches the input against the compiled set of regular expressions.
90
- * @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to match against.
91
- * @returns {number[]} An array of indices representing the patterns that successfully matched the input.
92
- */
93
- match(input: string | number[] | Uint8Array): number[];
94
- }
95
- export class MatcherInput {
96
- /**
97
- * Return the MatcherInput for UTF_16 encoding.
98
- * @returns {Utf16MatcherInput}
99
- */
100
- static utf16(charSequence: any): Utf16MatcherInput;
101
- /**
102
- * Return the MatcherInput for UTF_8 encoding.
103
- * @returns {Utf8MatcherInput}
104
- */
105
- static utf8(input: any): Utf8MatcherInput;
106
- }
107
3
  /**
108
4
  * Abstract the representations of input text supplied to Matcher.
109
5
  */
110
- export class MatcherInputBase {
6
+ export declare class MatcherInputBase {
111
7
  static Encoding: any;
112
8
  getEncoding(): void;
113
9
  /** @returns {string} */
114
10
  asCharSequence(): string;
115
- /** @returns {Uint8Array|number[]} */
116
- asBytes(): Uint8Array | number[];
11
+ /** @returns {Uint8Array|number[]|null} */
12
+ asBytes(): Uint8Array | number[] | null;
117
13
  /** @returns {number} */
118
14
  length(): number;
119
15
  /**
@@ -127,22 +23,67 @@ export class MatcherInputBase {
127
23
  */
128
24
  isUTF16Encoding(): boolean;
129
25
  }
26
+ declare class Utf8MatcherInput extends MatcherInputBase {
27
+ bytes: number[] | Uint8Array<ArrayBufferLike>;
28
+ /** @param {Uint8Array|number[]|null} bytes */
29
+ constructor(bytes?: Uint8Array | number[] | null);
30
+ getEncoding(): any;
31
+ /**
32
+ *
33
+ * @returns {string}
34
+ */
35
+ asCharSequence(): string;
36
+ /**
37
+ *
38
+ * @returns {Uint8Array|number[]|null}
39
+ */
40
+ asBytes(): Uint8Array | number[] | null;
41
+ /**
42
+ *
43
+ * @returns {number}
44
+ */
45
+ length(): number;
46
+ }
130
47
  declare class Utf16MatcherInput extends MatcherInputBase {
48
+ charSequence: string;
131
49
  /** @param {string|null} charSequence */
132
50
  constructor(charSequence?: string | null);
133
- charSequence: string;
134
51
  getEncoding(): any;
52
+ /**
53
+ *
54
+ * @returns {string}
55
+ */
56
+ asCharSequence(): string;
135
57
  /**
136
58
  *
137
59
  * @returns {number[]}
138
60
  */
139
61
  asBytes(): number[];
62
+ /**
63
+ *
64
+ * @returns {number}
65
+ */
66
+ length(): number;
140
67
  }
141
- declare class Utf8MatcherInput extends MatcherInputBase {
142
- /** @param {Uint8Array|number[]|null} bytes */
143
- constructor(bytes?: Uint8Array | number[] | null);
144
- bytes: number[] | Uint8Array<ArrayBufferLike>;
145
- getEncoding(): any;
68
+ export declare class MatcherInput {
69
+ /**
70
+ * Return the MatcherInput for UTF_16 encoding.
71
+ * @returns {Utf16MatcherInput}
72
+ */
73
+ static utf16(charSequence: any): Utf16MatcherInput;
74
+ /**
75
+ * Return the MatcherInput for UTF_8 encoding.
76
+ * @returns {Utf8MatcherInput}
77
+ */
78
+ static utf8(input: any): Utf8MatcherInput;
79
+ }
80
+ declare class LookbehindState {
81
+ pos: number;
82
+ pcs: Int32Array<any>;
83
+ size: number;
84
+ lbTable: Int32Array<any>;
85
+ constructor(prog: any);
86
+ reset(): void;
146
87
  }
147
88
  /**
148
89
  * A stateful iterator that interprets a regex {@code RE2JS} on a specific input.
@@ -166,7 +107,30 @@ declare class Utf8MatcherInput extends MatcherInputBase {
166
107
  *
167
108
  * @author rsc@google.com (Russ Cox)
168
109
  */
169
- export class Matcher {
110
+ export declare class Matcher {
111
+ /**
112
+ * The pattern being matched.
113
+ * @type {import('./index.js').RE2JS}
114
+ */
115
+ patternInput: RE2JS;
116
+ /** @type {number} */
117
+ patternGroupCount: number;
118
+ /** @type {number[]} */
119
+ groups: number[];
120
+ /** @type {Record<string, number>} */
121
+ namedGroups: Record<string, number>;
122
+ /** @type {number} */
123
+ numberOfInstructions: number;
124
+ /** @type {import('./Machine.js').LookbehindState|null} */
125
+ lookbehindState: LookbehindState | null;
126
+ /** @type {number} */
127
+ matcherInputLength: number;
128
+ /** @type {number} */
129
+ appendPos: number;
130
+ hasMatch: boolean;
131
+ hasGroups: boolean;
132
+ anchorFlag: number;
133
+ matcherInput: MatcherInputBase;
170
134
  /**
171
135
  * V8 and WebKit have historical hard limits on the number of arguments
172
136
  * that can be passed to a function. We cap replacer arguments to prevent
@@ -188,19 +152,6 @@ export class Matcher {
188
152
  * @param {string|number[]|Uint8Array|MatcherInputBase} input
189
153
  */
190
154
  constructor(pattern: RE2JS, input: string | number[] | Uint8Array | MatcherInputBase);
191
- /**
192
- * The pattern being matched.
193
- * @type {import('./index.js').RE2JS}
194
- */
195
- patternInput: RE2JS;
196
- /** @type {number} */
197
- patternGroupCount: number;
198
- /** @type {number[]} */
199
- groups: number[];
200
- /** @type {Record<string, number>} */
201
- namedGroups: Record<string, number>;
202
- /** @type {number} */
203
- numberOfInstructions: number;
204
155
  /**
205
156
  * Returns the {@code RE2JS} associated with this {@code Matcher}.
206
157
  * @returns {import('./index.js').RE2JS}
@@ -212,20 +163,12 @@ export class Matcher {
212
163
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
213
164
  */
214
165
  reset(): Matcher;
215
- /** @type {number} */
216
- matcherInputLength: number;
217
- /** @type {number} */
218
- appendPos: number;
219
- hasMatch: boolean;
220
- hasGroups: boolean;
221
- anchorFlag: number;
222
166
  /**
223
167
  * Resets the {@code Matcher} and changes the input.
224
168
  * @param {string|number[]|Uint8Array|MatcherInputBase} input
225
169
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
226
170
  */
227
171
  resetMatcherInput(input: string | number[] | Uint8Array | MatcherInputBase): Matcher;
228
- matcherInput: MatcherInputBase;
229
172
  /**
230
173
  * Returns the start of the named group of the most recent match, or -1 if the group was not
231
174
  * matched.
@@ -408,55 +351,58 @@ export class Matcher {
408
351
  */
409
352
  private buildReplacerArgs;
410
353
  }
411
- export class RE2JSException extends Error {
412
- /** @param {string} message */
413
- constructor(message: string);
414
- }
415
- /**
416
- * An exception thrown by the parser if the pattern was invalid.
417
- */
418
- export class RE2JSSyntaxException extends RE2JSException {
419
- /**
420
- * @param {string} error
421
- * @param {string|null} [input=null]
422
- */
423
- constructor(error: string, input?: string | null);
424
- /** @type {string} */
425
- error: string;
426
- /** @type {string|null} */
427
- input: string | null;
428
- /**
429
- * Retrieves the description of the error.
430
- * @returns {string}
431
- */
432
- getDescription(): string;
433
- /**
434
- * Retrieves the erroneous regular-expression pattern.
435
- * @returns {string|null}
436
- */
437
- getPattern(): string | null;
438
- }
439
- /**
440
- * An exception thrown by the compiler
441
- */
442
- export class RE2JSCompileException extends RE2JSException {
443
- }
444
- /**
445
- * An exception thrown by using groups
446
- */
447
- export class RE2JSGroupException extends RE2JSException {
448
- }
449
- /**
450
- * An exception thrown by flags
451
- */
452
- export class RE2JSFlagsException extends RE2JSException {
453
- }
454
- /**
455
- * An exception thrown for internal engine errors, such as corrupted bytecodes.
456
- */
457
- export class RE2JSInternalException extends RE2JSException {
354
+ declare class DFA {
355
+ prog: any;
356
+ maxMem: number;
357
+ stateCache: Map<any, any>;
358
+ stateCount: number;
359
+ startState: any;
360
+ failed: boolean;
361
+ stateBudget: number;
362
+ memBudget: number;
363
+ classBounds: Int32Array<ArrayBuffer>;
364
+ numClasses: number;
365
+ latin1Class: Int32Array<ArrayBuffer>;
366
+ static STATE_OVERHEAD: number;
367
+ static TABLE_OVERHEAD: number;
368
+ static PROGRESS_PER_STATE: number;
369
+ constructor(prog: any, maxMem?: number);
370
+ computeRuneClasses(): void;
371
+ runeClass(r: any): number;
372
+ searchClass(r: any): number;
373
+ computeClosure(pcs: any): {
374
+ pcs: Int32Array<ArrayBuffer>;
375
+ isMatch: boolean;
376
+ matchIDs: any[];
377
+ };
378
+ getState(pcs: any): any;
379
+ allocTable(state: any, anchor: any): any[];
380
+ clearCache(): void;
381
+ resetCache(current: any): any;
382
+ step(state: any, cls: any, rune: any, anchor: any): any;
383
+ start(): any;
384
+ run(input: any, pos: any, anchor: any, state: any, onState: any, noMatch: any): any;
385
+ match(input: any, pos: any, anchor: any): any;
386
+ matchSet(input: any, pos: any, anchor: any): any[];
458
387
  }
459
388
  declare class RE2 {
389
+ expr: any;
390
+ prog: any;
391
+ numSubexp: number;
392
+ longest: number;
393
+ cond: any;
394
+ prefix: any;
395
+ prefixUTF8: any;
396
+ prefixComplete: boolean;
397
+ prefixRune: number;
398
+ machinePool: any[];
399
+ dfa: DFA;
400
+ onepass: {
401
+ start: any;
402
+ numCap: any;
403
+ inst: any[];
404
+ };
405
+ prefilter: any;
460
406
  static initTest(expr: any): RE2;
461
407
  /**
462
408
  * Parses a regular expression and returns, if successful, an {@code RE2} instance that can be
@@ -494,25 +440,9 @@ declare class RE2 {
494
440
  */
495
441
  static match(pattern: any, s: any): boolean;
496
442
  constructor(expr: any, prog: any, numSubexp?: number, longest?: number);
497
- expr: any;
498
- prog: any;
499
- numSubexp: number;
500
- longest: number;
501
- cond: any;
502
- prefix: any;
503
- prefixUTF8: any;
504
- prefixComplete: boolean;
505
- prefixRune: number;
506
- machinePool: any[];
507
- dfa: DFA;
508
- onepass: {
509
- start: any;
510
- numCap: any;
511
- inst: any[];
512
- };
513
- prefilter: any;
514
443
  matchPrefixComplete(input: any, pos: any, anchor: any, ncap: any): number[];
515
- executeEngine(input: any, pos: any, anchor: any, ncap: any): any;
444
+ createLookbehindState(): LookbehindState;
445
+ executeEngine(input: any, pos: any, anchor: any, ncap: any, lbState?: any): any;
516
446
  /**
517
447
  * Returns the number of parenthesized subexpressions in this regular expression.
518
448
  */
@@ -525,7 +455,7 @@ declare class RE2 {
525
455
  reset(): void;
526
456
  put(m: any): void;
527
457
  toString(): any;
528
- doExecuteNFA(input: any, pos: any, anchor: any, ncap: any): any;
458
+ doExecuteNFA(input: any, pos: any, anchor: any, ncap: any, lbState?: any): any;
529
459
  match(s: any): boolean;
530
460
  /**
531
461
  * Matches the regular expression against input starting at position start and ending at position
@@ -539,10 +469,12 @@ declare class RE2 {
539
469
  * @param anchor the anchoring flag (UNANCHORED, ANCHOR_START, ANCHOR_BOTH)
540
470
  * @param group the array to fill with submatch positions
541
471
  * @param ngroup the number of array pairs to fill in
472
+ * @param lbState optional state carried between successive matches over the same input (see
473
+ * createLookbehindState); omit it to evaluate lookbehinds from the beginning of the input
542
474
  * @returns true if a match was found
543
475
  */
544
- matchWithGroup(input: any, start: any, end: any, anchor: any, ngroup: any): any[];
545
- matchMachineInput(input: any, start: any, end: any, anchor: any, ngroup: any): any[];
476
+ matchWithGroup(input: any, start: any, end: any, anchor: any, ngroup: any, lbState?: any): any[];
477
+ matchMachineInput(input: any, start: any, end: any, anchor: any, ngroup: any, lbState?: any): any[];
546
478
  /**
547
479
  * Returns true iff this regexp matches the UTF-8 byte array {@code b}.
548
480
  */
@@ -699,21 +631,134 @@ declare class RE2 {
699
631
  */
700
632
  findAllSubmatchIndex(s: any, n: any): any[];
701
633
  }
634
+ declare class Prog {
635
+ inst: any[];
636
+ start: number;
637
+ numCap: number;
638
+ lbStarts: any[];
639
+ numLb: number;
640
+ lbInst: Uint8Array<ArrayBuffer>;
641
+ constructor();
642
+ getInst(pc: any): any;
643
+ numInst(): number;
644
+ addInst(op: any): void;
645
+ markLookbehindInsts(): void;
646
+ skipNop(pc: any): any;
647
+ prefix(): (string | boolean)[];
648
+ startCond(): number;
649
+ patch(l: any, val: any): void;
650
+ append(l1: any, l2: any): any;
651
+ /**
652
+ *
653
+ * @returns {string}
654
+ */
655
+ toString(): string;
656
+ }
657
+ export declare class RE2Set {
658
+ anchor: number;
659
+ jsFlags: number;
660
+ maxMem: number;
661
+ re2Flags: number;
662
+ regexps: any[];
663
+ prog: Prog;
664
+ dfa: DFA;
665
+ dummyRe2: {
666
+ prog: Prog;
667
+ cond: number;
668
+ prefix: string;
669
+ prefixRune: number;
670
+ longest: boolean;
671
+ };
672
+ /** @type {number} */
673
+ static UNANCHORED: number;
674
+ /** @type {number} */
675
+ static ANCHOR_START: number;
676
+ /** @type {number} */
677
+ static ANCHOR_BOTH: number;
678
+ /**
679
+ * Constructs a new RE2Set with the specified anchor mode and flags.
680
+ * @param {number} [anchor=RE2Set.UNANCHORED] - The anchoring mode (e.g., RE2Set.UNANCHORED).
681
+ * @param {number} [flags=0] - The public flags to apply to all patterns in the set.
682
+ * @param {number} [maxMem=8388608] - The maximum memory in bytes to use for the DFA (default 8MB).
683
+ */
684
+ constructor(anchor?: number, flags?: number, maxMem?: number);
685
+ /**
686
+ * Adds a new regular expression pattern to the set.
687
+ * Patterns cannot be added after the set has been compiled.
688
+ * @param {string} pattern - The regular expression pattern to add.
689
+ * @returns {number} The integer index assigned to the added pattern.
690
+ * @throws {RE2JSCompileException} If patterns are added after compilation.
691
+ */
692
+ add(pattern: string): number;
693
+ /**
694
+ * Compiles the added patterns into a single state machine.
695
+ * This is automatically called on the first match if not called explicitly.
696
+ * @returns {void}
697
+ */
698
+ compile(): void;
699
+ /**
700
+ * Matches the input against the compiled set of regular expressions.
701
+ * @param {string|number[]|Uint8Array} input - The input string or UTF-8 byte array to match against.
702
+ * @returns {number[]} An array of indices representing the patterns that successfully matched the input.
703
+ */
704
+ match(input: string | number[] | Uint8Array): number[];
705
+ }
706
+ export declare class RE2JSException extends Error {
707
+ /** @param {string} message */
708
+ constructor(message: string);
709
+ }
702
710
  /**
703
- * Creates an RE2JS regex directly from a template literal.
704
- * @overload
705
- * @param {TemplateStringsArray} stringsOrFlags - The raw string segments of the template literal.
706
- * @param {...any} values - The interpolated values.
707
- * @returns {RE2JS}
711
+ * An exception thrown by the parser if the pattern was invalid.
708
712
  */
709
- export function re(stringsOrFlags: TemplateStringsArray, ...values: any[]): RE2JS;
713
+ export declare class RE2JSSyntaxException extends RE2JSException {
714
+ /** @type {string} */
715
+ error: string;
716
+ /** @type {string|null} */
717
+ input: string | null;
718
+ /**
719
+ * @param {string} error
720
+ * @param {string|null} [input=null]
721
+ */
722
+ constructor(error: string, input?: string | null);
723
+ /**
724
+ * Retrieves the description of the error.
725
+ * @returns {string}
726
+ */
727
+ getDescription(): string;
728
+ /**
729
+ * Retrieves the erroneous regular-expression pattern.
730
+ * @returns {string|null}
731
+ */
732
+ getPattern(): string | null;
733
+ }
710
734
  /**
711
- * Creates a template literal tag function with specific RE2JS flags.
712
- * @overload
713
- * @param {number} stringsOrFlags - The RE2JS flags to apply (e.g., RE2JS.CASE_INSENSITIVE).
714
- * @returns {(strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS}
735
+ * An exception thrown by the compiler
736
+ */
737
+ export declare class RE2JSCompileException extends RE2JSException {
738
+ /** @param {string} message */
739
+ constructor(message: string);
740
+ }
741
+ /**
742
+ * An exception thrown by using groups
743
+ */
744
+ export declare class RE2JSGroupException extends RE2JSException {
745
+ /** @param {string} message */
746
+ constructor(message: string);
747
+ }
748
+ /**
749
+ * An exception thrown by flags
750
+ */
751
+ export declare class RE2JSFlagsException extends RE2JSException {
752
+ /** @param {string} message */
753
+ constructor(message: string);
754
+ }
755
+ /**
756
+ * An exception thrown for internal engine errors, such as corrupted bytecodes.
715
757
  */
716
- export function re(stringsOrFlags: number): (strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS;
758
+ export declare class RE2JSInternalException extends RE2JSException {
759
+ /** @param {string} message */
760
+ constructor(message: string);
761
+ }
717
762
  /**
718
763
  * A compiled representation of an RE2 regular expression
719
764
  *
@@ -724,7 +769,11 @@ export function re(stringsOrFlags: number): (strings: TemplateStringsArray, ...t
724
769
  * @author rsc@google.com (Russ Cox)
725
770
  * @class
726
771
  */
727
- export class RE2JS {
772
+ export declare class RE2JS {
773
+ patternInput: string;
774
+ flagsInput: number;
775
+ /** @type {import('./RE2.js').RE2} */
776
+ re2Input: RE2;
728
777
  /**
729
778
  * Flag: case insensitive matching.
730
779
  */
@@ -812,10 +861,6 @@ export class RE2JS {
812
861
  * @param {number} flags
813
862
  */
814
863
  constructor(pattern: string, flags: number);
815
- patternInput: string;
816
- flagsInput: number;
817
- /** @type {import('./RE2.js').RE2} */
818
- re2Input: RE2;
819
864
  /**
820
865
  * Releases memory used by internal caches associated with this pattern. Does not change the
821
866
  * observable behaviour. Useful for tests that detect memory leaks via allocation tracking.
@@ -934,5 +979,25 @@ export class RE2JS {
934
979
  */
935
980
  equals(other: any): boolean;
936
981
  }
982
+ /**
983
+ * Creates an RE2JS regex directly from a template literal.
984
+ * @overload
985
+ * @param {TemplateStringsArray} stringsOrFlags - The raw string segments of the template literal.
986
+ * @param {...any} values - The interpolated values.
987
+ * @returns {RE2JS}
988
+ */
989
+ /**
990
+ * Creates a template literal tag function with specific RE2JS flags.
991
+ * @overload
992
+ * @param {number} stringsOrFlags - The RE2JS flags to apply (e.g., RE2JS.CASE_INSENSITIVE).
993
+ * @returns {(strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS}
994
+ */
995
+ /**
996
+ * Implementation signature
997
+ * @param {TemplateStringsArray | number} stringsOrFlags
998
+ * @param {...any} values
999
+ * @returns {RE2JS | ((strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS)}
1000
+ */
1001
+ export declare const re: (stringsOrFlags: TemplateStringsArray | number, ...values: any[]) => RE2JS | ((strings: TemplateStringsArray, ...tagValues: any[]) => RE2JS);
937
1002
 
938
1003
  export {};