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.
@@ -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.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
@@ -844,6 +844,7 @@ class MatcherInput {
844
844
  }
845
845
 
846
846
  class RE2JSException extends Error {
847
+ /** @param {string} message */
847
848
  constructor(message) {
848
849
  super(message);
849
850
  this.name = 'RE2JSException';
@@ -854,6 +855,10 @@ class RE2JSException extends Error {
854
855
  * An exception thrown by the parser if the pattern was invalid.
855
856
  */
856
857
  class RE2JSSyntaxException extends RE2JSException {
858
+ /**
859
+ * @param {string} error
860
+ * @param {string|null} [input=null]
861
+ */
857
862
  constructor(error, input = null) {
858
863
  let message = `error parsing regexp: ${error}`;
859
864
  if (input) {
@@ -862,12 +867,15 @@ class RE2JSSyntaxException extends RE2JSException {
862
867
  super(message);
863
868
  this.name = 'RE2JSSyntaxException';
864
869
  this.message = message;
870
+ /** @type {string} */
865
871
  this.error = error;
872
+ /** @type {string|null} */
866
873
  this.input = input;
867
874
  }
868
875
 
869
876
  /**
870
877
  * Retrieves the description of the error.
878
+ * @returns {string}
871
879
  */
872
880
  getDescription() {
873
881
  return this.error;
@@ -875,6 +883,7 @@ class RE2JSSyntaxException extends RE2JSException {
875
883
 
876
884
  /**
877
885
  * Retrieves the erroneous regular-expression pattern.
886
+ * @returns {string|null}
878
887
  */
879
888
  getPattern() {
880
889
  return this.input;
@@ -885,6 +894,7 @@ class RE2JSSyntaxException extends RE2JSException {
885
894
  * An exception thrown by the compiler
886
895
  */
887
896
  class RE2JSCompileException extends RE2JSException {
897
+ /** @param {string} message */
888
898
  constructor(message) {
889
899
  super(message);
890
900
  this.name = 'RE2JSCompileException';
@@ -895,6 +905,7 @@ class RE2JSCompileException extends RE2JSException {
895
905
  * An exception thrown by using groups
896
906
  */
897
907
  class RE2JSGroupException extends RE2JSException {
908
+ /** @param {string} message */
898
909
  constructor(message) {
899
910
  super(message);
900
911
  this.name = 'RE2JSGroupException';
@@ -905,6 +916,7 @@ class RE2JSGroupException extends RE2JSException {
905
916
  * An exception thrown by flags
906
917
  */
907
918
  class RE2JSFlagsException extends RE2JSException {
919
+ /** @param {string} message */
908
920
  constructor(message) {
909
921
  super(message);
910
922
  this.name = 'RE2JSFlagsException';
@@ -966,10 +978,14 @@ class Matcher {
966
978
  this.patternInput = pattern;
967
979
  const re2 = this.patternInput.re2();
968
980
  // The number of submatches (groups) in the pattern.
981
+ /** @type {number} */
969
982
  this.patternGroupCount = re2.numberOfCapturingGroups();
970
983
  // The group indexes, in [start, end) pairs. Zeroth pair is overall match.
984
+ /** @type {number[]} */
971
985
  this.groups = [];
986
+ /** @type {Record<string, number>} */
972
987
  this.namedGroups = re2.namedGroups;
988
+ /** @type {number} */
973
989
  this.numberOfInstructions = re2.numberOfInstructions();
974
990
  if (input instanceof MatcherInputBase) {
975
991
  this.resetMatcherInput(input);
@@ -995,8 +1011,10 @@ class Matcher {
995
1011
  */
996
1012
  reset() {
997
1013
  // The input length in UTF16 codes.
1014
+ /** @type {number} */
998
1015
  this.matcherInputLength = this.matcherInput.length();
999
1016
  // The append position: where the next append should start.
1017
+ /** @type {number} */
1000
1018
  this.appendPos = 0;
1001
1019
  // Is there a current match?
1002
1020
  this.hasMatch = false;
@@ -1010,6 +1028,7 @@ class Matcher {
1010
1028
 
1011
1029
  /**
1012
1030
  * Resets the {@code Matcher} and changes the input.
1031
+ * @param {Utf8MatcherInput|Utf16MatcherInput} input
1013
1032
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
1014
1033
  */
1015
1034
  resetMatcherInput(input) {
@@ -1152,7 +1171,7 @@ class Matcher {
1152
1171
  * Matches the input against the pattern (unanchored), starting at a specified position. If there
1153
1172
  * is a match, {@code find} sets the match state to describe it.
1154
1173
  *
1155
- * @param {string|number} [start=null] the input position where the search begins
1174
+ * @param {number} [start=null] the input position where the search begins
1156
1175
  * @returns {boolean} if it finds a match
1157
1176
  * @throws IndexOutOfBoundsException if start is not a valid input position
1158
1177
  */
@@ -6200,7 +6219,7 @@ class RE2JS {
6200
6219
  /**
6201
6220
  * Return a map of the capturing groups in this matcher's pattern, where key is the name and value
6202
6221
  * is the index of the group in the pattern.
6203
- * @returns {*}
6222
+ * @returns {Record<string, number>}
6204
6223
  */
6205
6224
  namedGroups() {
6206
6225
  return this.re2Input.namedGroups;
@@ -6222,6 +6241,7 @@ class RE2JS {
6222
6241
  }
6223
6242
  }
6224
6243
 
6244
+ exports.Matcher = Matcher;
6225
6245
  exports.RE2JS = RE2JS;
6226
6246
  exports.RE2JSCompileException = RE2JSCompileException;
6227
6247
  exports.RE2JSException = RE2JSException;