@@ -149,6 +149,31 @@ export namespace RegExpValidator {
149
149
*/
150
150
onLiteralLeave ?: ( start : number , end : number ) => void
151
151
152
+ /**
153
+ * A function that is called when the validator found flags.
154
+ * @param start The 0-based index of the first character.
155
+ * @param end The next 0-based index of the last character.
156
+ * @param flags.global `g` flag.
157
+ * @param flags.ignoreCase `i` flag.
158
+ * @param flags.multiline `m` flag.
159
+ * @param flags.unicode `u` flag.
160
+ * @param flags.sticky `y` flag.
161
+ * @param flags.dotAll `s` flag.
162
+ * @param flags.hasIndices `d` flag.
163
+ */
164
+ onRegExpFlags ?: (
165
+ start : number ,
166
+ end : number ,
167
+ flags : {
168
+ global : boolean
169
+ ignoreCase : boolean
170
+ multiline : boolean
171
+ unicode : boolean
172
+ sticky : boolean
173
+ dotAll : boolean
174
+ hasIndices : boolean
175
+ } ,
176
+ ) => void
152
177
/**
153
178
* A function that is called when the validator found flags.
154
179
* @param start The 0-based index of the first character.
@@ -160,6 +185,8 @@ export namespace RegExpValidator {
160
185
* @param sticky `y` flag.
161
186
* @param dotAll `s` flag.
162
187
* @param hasIndices `d` flag.
188
+ *
189
+ * @deprecated Use `onRegExpFlags` instead.
163
190
*/
164
191
onFlags ?: (
165
192
start : number ,
@@ -535,17 +562,15 @@ export class RegExpValidator {
535
562
this . raise ( `Invalid flag '${ source [ i ] } '` )
536
563
}
537
564
}
538
- this . onFlags (
539
- start ,
540
- end ,
565
+ this . onRegExpFlags ( start , end , {
541
566
global,
542
567
ignoreCase,
543
568
multiline,
544
569
unicode,
545
570
sticky,
546
571
dotAll,
547
572
hasIndices,
548
- )
573
+ } )
549
574
}
550
575
551
576
/**
@@ -599,28 +624,34 @@ export class RegExpValidator {
599
624
}
600
625
}
601
626
602
- private onFlags (
627
+ private onRegExpFlags (
603
628
start : number ,
604
629
end : number ,
605
- global : boolean ,
606
- ignoreCase : boolean ,
607
- multiline : boolean ,
608
- unicode : boolean ,
609
- sticky : boolean ,
610
- dotAll : boolean ,
611
- hasIndices : boolean ,
630
+ flags : {
631
+ global : boolean
632
+ ignoreCase : boolean
633
+ multiline : boolean
634
+ unicode : boolean
635
+ sticky : boolean
636
+ dotAll : boolean
637
+ hasIndices : boolean
638
+ } ,
612
639
) : void {
640
+ if ( this . _options . onRegExpFlags ) {
641
+ this . _options . onRegExpFlags ( start , end , flags )
642
+ }
643
+ // Backward compatibility
613
644
if ( this . _options . onFlags ) {
614
645
this . _options . onFlags (
615
646
start ,
616
647
end ,
617
- global ,
618
- ignoreCase ,
619
- multiline ,
620
- unicode ,
621
- sticky ,
622
- dotAll ,
623
- hasIndices ,
648
+ flags . global ,
649
+ flags . ignoreCase ,
650
+ flags . multiline ,
651
+ flags . unicode ,
652
+ flags . sticky ,
653
+ flags . dotAll ,
654
+ flags . hasIndices ,
624
655
)
625
656
}
626
657
}
0 commit comments