re2js 1.2.2 → 1.2.3
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.cjs.cjs +23 -3
- package/build/index.cjs.cjs.map +1 -1
- package/build/index.esm.d.ts +225 -209
- package/build/index.esm.d.ts.map +1 -1
- package/build/index.esm.js +23 -4
- package/build/index.esm.js.map +1 -1
- package/build/index.umd.js +23 -3
- package/build/index.umd.js.map +1 -1
- package/package.json +7 -7
package/build/index.umd.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* re2js
|
|
3
3
|
* RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching
|
|
4
4
|
*
|
|
5
|
-
* @version v1.2.
|
|
5
|
+
* @version v1.2.3
|
|
6
6
|
* @author Alexey Vasiliev
|
|
7
7
|
* @homepage https://github.com/le0pard/re2js#readme
|
|
8
8
|
* @repository github:le0pard/re2js
|
|
@@ -848,6 +848,7 @@
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
class RE2JSException extends Error {
|
|
851
|
+
/** @param {string} message */
|
|
851
852
|
constructor(message) {
|
|
852
853
|
super(message);
|
|
853
854
|
this.name = 'RE2JSException';
|
|
@@ -858,6 +859,10 @@
|
|
|
858
859
|
* An exception thrown by the parser if the pattern was invalid.
|
|
859
860
|
*/
|
|
860
861
|
class RE2JSSyntaxException extends RE2JSException {
|
|
862
|
+
/**
|
|
863
|
+
* @param {string} error
|
|
864
|
+
* @param {string|null} [input=null]
|
|
865
|
+
*/
|
|
861
866
|
constructor(error, input = null) {
|
|
862
867
|
let message = `error parsing regexp: ${error}`;
|
|
863
868
|
if (input) {
|
|
@@ -866,12 +871,15 @@
|
|
|
866
871
|
super(message);
|
|
867
872
|
this.name = 'RE2JSSyntaxException';
|
|
868
873
|
this.message = message;
|
|
874
|
+
/** @type {string} */
|
|
869
875
|
this.error = error;
|
|
876
|
+
/** @type {string|null} */
|
|
870
877
|
this.input = input;
|
|
871
878
|
}
|
|
872
879
|
|
|
873
880
|
/**
|
|
874
881
|
* Retrieves the description of the error.
|
|
882
|
+
* @returns {string}
|
|
875
883
|
*/
|
|
876
884
|
getDescription() {
|
|
877
885
|
return this.error;
|
|
@@ -879,6 +887,7 @@
|
|
|
879
887
|
|
|
880
888
|
/**
|
|
881
889
|
* Retrieves the erroneous regular-expression pattern.
|
|
890
|
+
* @returns {string|null}
|
|
882
891
|
*/
|
|
883
892
|
getPattern() {
|
|
884
893
|
return this.input;
|
|
@@ -889,6 +898,7 @@
|
|
|
889
898
|
* An exception thrown by the compiler
|
|
890
899
|
*/
|
|
891
900
|
class RE2JSCompileException extends RE2JSException {
|
|
901
|
+
/** @param {string} message */
|
|
892
902
|
constructor(message) {
|
|
893
903
|
super(message);
|
|
894
904
|
this.name = 'RE2JSCompileException';
|
|
@@ -899,6 +909,7 @@
|
|
|
899
909
|
* An exception thrown by using groups
|
|
900
910
|
*/
|
|
901
911
|
class RE2JSGroupException extends RE2JSException {
|
|
912
|
+
/** @param {string} message */
|
|
902
913
|
constructor(message) {
|
|
903
914
|
super(message);
|
|
904
915
|
this.name = 'RE2JSGroupException';
|
|
@@ -909,6 +920,7 @@
|
|
|
909
920
|
* An exception thrown by flags
|
|
910
921
|
*/
|
|
911
922
|
class RE2JSFlagsException extends RE2JSException {
|
|
923
|
+
/** @param {string} message */
|
|
912
924
|
constructor(message) {
|
|
913
925
|
super(message);
|
|
914
926
|
this.name = 'RE2JSFlagsException';
|
|
@@ -970,10 +982,14 @@
|
|
|
970
982
|
this.patternInput = pattern;
|
|
971
983
|
const re2 = this.patternInput.re2();
|
|
972
984
|
// The number of submatches (groups) in the pattern.
|
|
985
|
+
/** @type {number} */
|
|
973
986
|
this.patternGroupCount = re2.numberOfCapturingGroups();
|
|
974
987
|
// The group indexes, in [start, end) pairs. Zeroth pair is overall match.
|
|
988
|
+
/** @type {number[]} */
|
|
975
989
|
this.groups = [];
|
|
990
|
+
/** @type {Record<string, number>} */
|
|
976
991
|
this.namedGroups = re2.namedGroups;
|
|
992
|
+
/** @type {number} */
|
|
977
993
|
this.numberOfInstructions = re2.numberOfInstructions();
|
|
978
994
|
if (input instanceof MatcherInputBase) {
|
|
979
995
|
this.resetMatcherInput(input);
|
|
@@ -999,8 +1015,10 @@
|
|
|
999
1015
|
*/
|
|
1000
1016
|
reset() {
|
|
1001
1017
|
// The input length in UTF16 codes.
|
|
1018
|
+
/** @type {number} */
|
|
1002
1019
|
this.matcherInputLength = this.matcherInput.length();
|
|
1003
1020
|
// The append position: where the next append should start.
|
|
1021
|
+
/** @type {number} */
|
|
1004
1022
|
this.appendPos = 0;
|
|
1005
1023
|
// Is there a current match?
|
|
1006
1024
|
this.hasMatch = false;
|
|
@@ -1014,6 +1032,7 @@
|
|
|
1014
1032
|
|
|
1015
1033
|
/**
|
|
1016
1034
|
* Resets the {@code Matcher} and changes the input.
|
|
1035
|
+
* @param {Utf8MatcherInput|Utf16MatcherInput} input
|
|
1017
1036
|
* @returns {Matcher} the {@code Matcher} itself, for chained method calls
|
|
1018
1037
|
*/
|
|
1019
1038
|
resetMatcherInput(input) {
|
|
@@ -1156,7 +1175,7 @@
|
|
|
1156
1175
|
* Matches the input against the pattern (unanchored), starting at a specified position. If there
|
|
1157
1176
|
* is a match, {@code find} sets the match state to describe it.
|
|
1158
1177
|
*
|
|
1159
|
-
* @param {
|
|
1178
|
+
* @param {number} [start=null] the input position where the search begins
|
|
1160
1179
|
* @returns {boolean} if it finds a match
|
|
1161
1180
|
* @throws IndexOutOfBoundsException if start is not a valid input position
|
|
1162
1181
|
*/
|
|
@@ -6204,7 +6223,7 @@
|
|
|
6204
6223
|
/**
|
|
6205
6224
|
* Return a map of the capturing groups in this matcher's pattern, where key is the name and value
|
|
6206
6225
|
* is the index of the group in the pattern.
|
|
6207
|
-
* @returns {
|
|
6226
|
+
* @returns {Record<string, number>}
|
|
6208
6227
|
*/
|
|
6209
6228
|
namedGroups() {
|
|
6210
6229
|
return this.re2Input.namedGroups;
|
|
@@ -6226,6 +6245,7 @@
|
|
|
6226
6245
|
}
|
|
6227
6246
|
}
|
|
6228
6247
|
|
|
6248
|
+
exports.Matcher = Matcher;
|
|
6229
6249
|
exports.RE2JS = RE2JS;
|
|
6230
6250
|
exports.RE2JSCompileException = RE2JSCompileException;
|
|
6231
6251
|
exports.RE2JSException = RE2JSException;
|