re2js 2.8.3 → 2.8.5

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/README.md CHANGED
@@ -228,6 +228,37 @@ matchString.group() // 'e'
228
228
  matchString.find(7) // false
229
229
  ```
230
230
 
231
+ ### Executing a Search (`exec`)
232
+
233
+ If you want a native, 1:1 drop-in replacement for JavaScript's `RegExp.prototype.exec()`, you can use the `.exec()` method.
234
+
235
+ Instead of dealing with a stateful `Matcher` object, `exec()` performs a single search and returns a standard `RegExpExecArray`-shaped result, or `null` if no match is found. It includes the `.index`, `.input`, and `.groups` properties, and accurately maps unmatched optional capture groups to `undefined` (just like native JavaScript).
236
+
237
+ ```js
238
+ import { RE2JS } from 're2js'
239
+
240
+ const re = RE2JS.compile('(?P<first>\\w+) (?:(?P<middle>\\w+) )?(?P<last>\\w+)');
241
+ const result = re.exec('John Doe');
242
+
243
+ if (result !== null) {
244
+ console.log(result[0]); // "John Doe" (Full match)
245
+ console.log(result[1]); // "John" (Group 1)
246
+ console.log(result[2]); // undefined (Group 2 didn't match)
247
+ console.log(result[3]); // "Doe" (Group 3)
248
+
249
+ console.log(result.index); // 0
250
+ console.log(result.input); // "John Doe"
251
+
252
+ // Named groups dictionary
253
+ console.log(result.groups.first); // "John"
254
+ console.log(result.groups.middle); // undefined
255
+ console.log(result.groups.last); // "Doe"
256
+ }
257
+
258
+ ```
259
+
260
+ ***Performance Note:** If you are running `exec()` inside a `while` loop to manually extract multiple matches globally, it is highly recommended to use `.matchAll()` instead, as it is cleaner, strictly stateless, and avoids infinite loop pitfalls.*
261
+
231
262
  ### Iterating Over Matches (`matchAll`)
232
263
 
233
264
  For a more modern, JavaScript-native developer experience, RE2JS provides a `.matchAll()` method. This returns an ES6 `IterableIterator`, allowing you to safely and cleanly iterate over matches using `for...of` loops or the array spread operator `[...]`.
package/build/index.cjs 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 v2.8.3
5
+ * @version v2.8.5
6
6
  * @author Oleksii Vasyliev
7
7
  * @homepage https://github.com/le0pard/re2js#readme
8
8
  * @repository github:le0pard/re2js
@@ -57,7 +57,7 @@ for (let i = 0; i < ASCII_SIZE; i++) {
57
57
  else ASCII_TO_LOWER[i] = i;
58
58
  }
59
59
  var Codepoint = class {
60
- static CODES = new Map([
60
+ static CODES = /* @__PURE__ */ new Map([
61
61
  ["\x07", 7],
62
62
  ["\b", 8],
63
63
  [" ", 9],
@@ -168,7 +168,7 @@ var UnicodeRangeTable = class {
168
168
  };
169
169
  //#endregion
170
170
  //#region src/UnicodeTables.js
171
- const B64_MAP = new Uint8Array(256);
171
+ const B64_MAP = /* @__PURE__ */ new Uint8Array(256);
172
172
  for (let i = 0, b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; i < 64; i++) B64_MAP[b.charCodeAt(i)] = i;
173
173
  const decodeVLQ = (str) => {
174
174
  const res = [];
@@ -1246,11 +1246,13 @@ var Matcher = class Matcher {
1246
1246
  }
1247
1247
  /**
1248
1248
  * Resets the {@code Matcher} and changes the input.
1249
- * @param {MatcherInputBase} input
1249
+ * @param {string|number[]|Uint8Array|MatcherInputBase} input
1250
1250
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
1251
1251
  */
1252
1252
  resetMatcherInput(input) {
1253
1253
  if (input === null) throw new Error("input is null");
1254
+ if (!(input instanceof MatcherInputBase)) if (Utils.isByteArray(input)) input = MatcherInput.utf8(input);
1255
+ else input = MatcherInput.utf16(input);
1254
1256
  this.matcherInput = input;
1255
1257
  this.reset();
1256
1258
  return this;
@@ -2426,14 +2428,14 @@ const MAX_BACKTRACK_VECTOR = 256 * 1024;
2426
2428
  var BitState = class {
2427
2429
  constructor() {
2428
2430
  this.end = 0;
2429
- this.cap = new Int32Array(0);
2430
- this.matchcap = new Int32Array(0);
2431
+ this.cap = /* @__PURE__ */ new Int32Array(0);
2432
+ this.matchcap = /* @__PURE__ */ new Int32Array(0);
2431
2433
  this.ncap = 0;
2432
2434
  this.jobPc = new Int32Array(INITIAL_JOB_CAPACITY);
2433
2435
  this.jobArg = new Uint8Array(INITIAL_JOB_CAPACITY);
2434
2436
  this.jobPos = new Int32Array(INITIAL_JOB_CAPACITY);
2435
2437
  this.jobLen = 0;
2436
- this.visited = new Uint32Array(0);
2438
+ this.visited = /* @__PURE__ */ new Uint32Array(0);
2437
2439
  }
2438
2440
  reset(prog, end, ncap) {
2439
2441
  this.end = end;
@@ -3943,7 +3945,7 @@ const code3 = [
3943
3945
  97,
3944
3946
  122
3945
3947
  ];
3946
- const PERL_GROUPS = new Map([
3948
+ const PERL_GROUPS = /* @__PURE__ */ new Map([
3947
3949
  ["\\d", new CharGroup(1, code1)],
3948
3950
  ["\\D", new CharGroup(-1, code1)],
3949
3951
  ["\\s", new CharGroup(1, code2)],
@@ -4017,7 +4019,7 @@ const code17 = [
4017
4019
  97,
4018
4020
  102
4019
4021
  ];
4020
- const POSIX_GROUPS = new Map([
4022
+ const POSIX_GROUPS = /* @__PURE__ */ new Map([
4021
4023
  ["[:alnum:]", new CharGroup(1, code4)],
4022
4024
  ["[:^alnum:]", new CharGroup(-1, code4)],
4023
4025
  ["[:alpha:]", new CharGroup(1, code5)],
@@ -6364,6 +6366,33 @@ var RE2JS = class RE2JS {
6364
6366
  return this.re2Input.executeEngine(machineInput, 0, RE2Flags.ANCHOR_BOTH, 0) !== null;
6365
6367
  }
6366
6368
  /**
6369
+ * Executes a search for a match in a specified string.
6370
+ * Returns a result array, or null if no match is found.
6371
+ * The returned array perfectly mirrors standard JavaScript `RegExpExecArray`,
6372
+ * including `.index`, `.input`, and `.groups` properties.
6373
+ *
6374
+ * @param {string|number[]|Uint8Array} input the input string or byte array
6375
+ * @returns {Array|null} the match array with index, input, and groups properties, or null
6376
+ */
6377
+ exec(input) {
6378
+ const m = this.matcher(input);
6379
+ if (!m.find()) return null;
6380
+ const result = [m.group(0)];
6381
+ for (let i = 1; i <= m.groupCount(); i++) {
6382
+ const val = m.group(i);
6383
+ result.push(val === null ? void 0 : val);
6384
+ }
6385
+ result.index = m.start(0);
6386
+ result.input = input;
6387
+ const namedGroups = this.namedGroups();
6388
+ if (Object.keys(namedGroups).length > 0) {
6389
+ const parsedGroups = m.getNamedGroups();
6390
+ for (const key in parsedGroups) if (parsedGroups[key] === null) parsedGroups[key] = void 0;
6391
+ result.groups = parsedGroups;
6392
+ } else result.groups = void 0;
6393
+ return result;
6394
+ }
6395
+ /**
6367
6396
  * Splits input around instances of the regular expression. It returns an array giving the strings
6368
6397
  * that occur before, between, and after instances of the regular expression.
6369
6398
  *
@@ -6415,7 +6444,7 @@ var RE2JS = class RE2JS {
6415
6444
  * including capturing groups.
6416
6445
  *
6417
6446
  * @param {string|number[]|Uint8Array} input the input string or byte array
6418
- * @returns {IterableIterator<Array>}
6447
+ * @returns {IterableIterator<RegExpMatchArray>}
6419
6448
  */
6420
6449
  *matchAll(input) {
6421
6450
  const m = this.matcher(input);
package/build/index.d.cts CHANGED
@@ -221,10 +221,10 @@ export class Matcher {
221
221
  anchorFlag: number;
222
222
  /**
223
223
  * Resets the {@code Matcher} and changes the input.
224
- * @param {MatcherInputBase} input
224
+ * @param {string|number[]|Uint8Array|MatcherInputBase} input
225
225
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
226
226
  */
227
- resetMatcherInput(input: MatcherInputBase): Matcher;
227
+ resetMatcherInput(input: string | number[] | Uint8Array | MatcherInputBase): Matcher;
228
228
  matcherInput: MatcherInputBase;
229
229
  /**
230
230
  * Returns the start of the named group of the most recent match, or -1 if the group was not
@@ -873,6 +873,16 @@ export class RE2JS {
873
873
  * @returns {boolean} `true` if the exact input string fully matches the pattern, `false` otherwise.
874
874
  */
875
875
  testExact(input: string | number[] | Uint8Array): boolean;
876
+ /**
877
+ * Executes a search for a match in a specified string.
878
+ * Returns a result array, or null if no match is found.
879
+ * The returned array perfectly mirrors standard JavaScript `RegExpExecArray`,
880
+ * including `.index`, `.input`, and `.groups` properties.
881
+ *
882
+ * @param {string|number[]|Uint8Array} input the input string or byte array
883
+ * @returns {Array|null} the match array with index, input, and groups properties, or null
884
+ */
885
+ exec(input: string | number[] | Uint8Array): any[] | null;
876
886
  /**
877
887
  * Splits input around instances of the regular expression. It returns an array giving the strings
878
888
  * that occur before, between, and after instances of the regular expression.
@@ -892,9 +902,9 @@ export class RE2JS {
892
902
  * including capturing groups.
893
903
  *
894
904
  * @param {string|number[]|Uint8Array} input the input string or byte array
895
- * @returns {IterableIterator<Array>}
905
+ * @returns {IterableIterator<RegExpMatchArray>}
896
906
  */
897
- matchAll(input: string | number[] | Uint8Array): IterableIterator<any[]>;
907
+ matchAll(input: string | number[] | Uint8Array): IterableIterator<RegExpMatchArray>;
898
908
  /**
899
909
  *
900
910
  * @returns {string}
package/build/index.d.ts CHANGED
@@ -221,10 +221,10 @@ export class Matcher {
221
221
  anchorFlag: number;
222
222
  /**
223
223
  * Resets the {@code Matcher} and changes the input.
224
- * @param {MatcherInputBase} input
224
+ * @param {string|number[]|Uint8Array|MatcherInputBase} input
225
225
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
226
226
  */
227
- resetMatcherInput(input: MatcherInputBase): Matcher;
227
+ resetMatcherInput(input: string | number[] | Uint8Array | MatcherInputBase): Matcher;
228
228
  matcherInput: MatcherInputBase;
229
229
  /**
230
230
  * Returns the start of the named group of the most recent match, or -1 if the group was not
@@ -873,6 +873,16 @@ export class RE2JS {
873
873
  * @returns {boolean} `true` if the exact input string fully matches the pattern, `false` otherwise.
874
874
  */
875
875
  testExact(input: string | number[] | Uint8Array): boolean;
876
+ /**
877
+ * Executes a search for a match in a specified string.
878
+ * Returns a result array, or null if no match is found.
879
+ * The returned array perfectly mirrors standard JavaScript `RegExpExecArray`,
880
+ * including `.index`, `.input`, and `.groups` properties.
881
+ *
882
+ * @param {string|number[]|Uint8Array} input the input string or byte array
883
+ * @returns {Array|null} the match array with index, input, and groups properties, or null
884
+ */
885
+ exec(input: string | number[] | Uint8Array): any[] | null;
876
886
  /**
877
887
  * Splits input around instances of the regular expression. It returns an array giving the strings
878
888
  * that occur before, between, and after instances of the regular expression.
@@ -892,9 +902,9 @@ export class RE2JS {
892
902
  * including capturing groups.
893
903
  *
894
904
  * @param {string|number[]|Uint8Array} input the input string or byte array
895
- * @returns {IterableIterator<Array>}
905
+ * @returns {IterableIterator<RegExpMatchArray>}
896
906
  */
897
- matchAll(input: string | number[] | Uint8Array): IterableIterator<any[]>;
907
+ matchAll(input: string | number[] | Uint8Array): IterableIterator<RegExpMatchArray>;
898
908
  /**
899
909
  *
900
910
  * @returns {string}
package/build/index.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 v2.8.3
5
+ * @version v2.8.5
6
6
  * @author Oleksii Vasyliev
7
7
  * @homepage https://github.com/le0pard/re2js#readme
8
8
  * @repository github:le0pard/re2js
@@ -56,7 +56,7 @@ for (let i = 0; i < ASCII_SIZE; i++) {
56
56
  else ASCII_TO_LOWER[i] = i;
57
57
  }
58
58
  var Codepoint = class {
59
- static CODES = new Map([
59
+ static CODES = /* @__PURE__ */ new Map([
60
60
  ["\x07", 7],
61
61
  ["\b", 8],
62
62
  [" ", 9],
@@ -167,7 +167,7 @@ var UnicodeRangeTable = class {
167
167
  };
168
168
  //#endregion
169
169
  //#region src/UnicodeTables.js
170
- const B64_MAP = new Uint8Array(256);
170
+ const B64_MAP = /* @__PURE__ */ new Uint8Array(256);
171
171
  for (let i = 0, b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; i < 64; i++) B64_MAP[b.charCodeAt(i)] = i;
172
172
  const decodeVLQ = (str) => {
173
173
  const res = [];
@@ -1245,11 +1245,13 @@ var Matcher = class Matcher {
1245
1245
  }
1246
1246
  /**
1247
1247
  * Resets the {@code Matcher} and changes the input.
1248
- * @param {MatcherInputBase} input
1248
+ * @param {string|number[]|Uint8Array|MatcherInputBase} input
1249
1249
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
1250
1250
  */
1251
1251
  resetMatcherInput(input) {
1252
1252
  if (input === null) throw new Error("input is null");
1253
+ if (!(input instanceof MatcherInputBase)) if (Utils.isByteArray(input)) input = MatcherInput.utf8(input);
1254
+ else input = MatcherInput.utf16(input);
1253
1255
  this.matcherInput = input;
1254
1256
  this.reset();
1255
1257
  return this;
@@ -2425,14 +2427,14 @@ const MAX_BACKTRACK_VECTOR = 256 * 1024;
2425
2427
  var BitState = class {
2426
2428
  constructor() {
2427
2429
  this.end = 0;
2428
- this.cap = new Int32Array(0);
2429
- this.matchcap = new Int32Array(0);
2430
+ this.cap = /* @__PURE__ */ new Int32Array(0);
2431
+ this.matchcap = /* @__PURE__ */ new Int32Array(0);
2430
2432
  this.ncap = 0;
2431
2433
  this.jobPc = new Int32Array(INITIAL_JOB_CAPACITY);
2432
2434
  this.jobArg = new Uint8Array(INITIAL_JOB_CAPACITY);
2433
2435
  this.jobPos = new Int32Array(INITIAL_JOB_CAPACITY);
2434
2436
  this.jobLen = 0;
2435
- this.visited = new Uint32Array(0);
2437
+ this.visited = /* @__PURE__ */ new Uint32Array(0);
2436
2438
  }
2437
2439
  reset(prog, end, ncap) {
2438
2440
  this.end = end;
@@ -3942,7 +3944,7 @@ const code3 = [
3942
3944
  97,
3943
3945
  122
3944
3946
  ];
3945
- const PERL_GROUPS = new Map([
3947
+ const PERL_GROUPS = /* @__PURE__ */ new Map([
3946
3948
  ["\\d", new CharGroup(1, code1)],
3947
3949
  ["\\D", new CharGroup(-1, code1)],
3948
3950
  ["\\s", new CharGroup(1, code2)],
@@ -4016,7 +4018,7 @@ const code17 = [
4016
4018
  97,
4017
4019
  102
4018
4020
  ];
4019
- const POSIX_GROUPS = new Map([
4021
+ const POSIX_GROUPS = /* @__PURE__ */ new Map([
4020
4022
  ["[:alnum:]", new CharGroup(1, code4)],
4021
4023
  ["[:^alnum:]", new CharGroup(-1, code4)],
4022
4024
  ["[:alpha:]", new CharGroup(1, code5)],
@@ -6363,6 +6365,33 @@ var RE2JS = class RE2JS {
6363
6365
  return this.re2Input.executeEngine(machineInput, 0, RE2Flags.ANCHOR_BOTH, 0) !== null;
6364
6366
  }
6365
6367
  /**
6368
+ * Executes a search for a match in a specified string.
6369
+ * Returns a result array, or null if no match is found.
6370
+ * The returned array perfectly mirrors standard JavaScript `RegExpExecArray`,
6371
+ * including `.index`, `.input`, and `.groups` properties.
6372
+ *
6373
+ * @param {string|number[]|Uint8Array} input the input string or byte array
6374
+ * @returns {Array|null} the match array with index, input, and groups properties, or null
6375
+ */
6376
+ exec(input) {
6377
+ const m = this.matcher(input);
6378
+ if (!m.find()) return null;
6379
+ const result = [m.group(0)];
6380
+ for (let i = 1; i <= m.groupCount(); i++) {
6381
+ const val = m.group(i);
6382
+ result.push(val === null ? void 0 : val);
6383
+ }
6384
+ result.index = m.start(0);
6385
+ result.input = input;
6386
+ const namedGroups = this.namedGroups();
6387
+ if (Object.keys(namedGroups).length > 0) {
6388
+ const parsedGroups = m.getNamedGroups();
6389
+ for (const key in parsedGroups) if (parsedGroups[key] === null) parsedGroups[key] = void 0;
6390
+ result.groups = parsedGroups;
6391
+ } else result.groups = void 0;
6392
+ return result;
6393
+ }
6394
+ /**
6366
6395
  * Splits input around instances of the regular expression. It returns an array giving the strings
6367
6396
  * that occur before, between, and after instances of the regular expression.
6368
6397
  *
@@ -6414,7 +6443,7 @@ var RE2JS = class RE2JS {
6414
6443
  * including capturing groups.
6415
6444
  *
6416
6445
  * @param {string|number[]|Uint8Array} input the input string or byte array
6417
- * @returns {IterableIterator<Array>}
6446
+ * @returns {IterableIterator<RegExpMatchArray>}
6418
6447
  */
6419
6448
  *matchAll(input) {
6420
6449
  const m = this.matcher(input);
@@ -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 v2.8.3
5
+ * @version v2.8.5
6
6
  * @author Oleksii Vasyliev
7
7
  * @homepage https://github.com/le0pard/re2js#readme
8
8
  * @repository github:le0pard/re2js
@@ -60,7 +60,7 @@
60
60
  else ASCII_TO_LOWER[i] = i;
61
61
  }
62
62
  var Codepoint = class {
63
- static CODES = new Map([
63
+ static CODES = /* @__PURE__ */ new Map([
64
64
  ["\x07", 7],
65
65
  ["\b", 8],
66
66
  [" ", 9],
@@ -171,7 +171,7 @@
171
171
  };
172
172
  //#endregion
173
173
  //#region src/UnicodeTables.js
174
- const B64_MAP = new Uint8Array(256);
174
+ const B64_MAP = /* @__PURE__ */ new Uint8Array(256);
175
175
  for (let i = 0, b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; i < 64; i++) B64_MAP[b.charCodeAt(i)] = i;
176
176
  const decodeVLQ = (str) => {
177
177
  const res = [];
@@ -1249,11 +1249,13 @@
1249
1249
  }
1250
1250
  /**
1251
1251
  * Resets the {@code Matcher} and changes the input.
1252
- * @param {MatcherInputBase} input
1252
+ * @param {string|number[]|Uint8Array|MatcherInputBase} input
1253
1253
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
1254
1254
  */
1255
1255
  resetMatcherInput(input) {
1256
1256
  if (input === null) throw new Error("input is null");
1257
+ if (!(input instanceof MatcherInputBase)) if (Utils.isByteArray(input)) input = MatcherInput.utf8(input);
1258
+ else input = MatcherInput.utf16(input);
1257
1259
  this.matcherInput = input;
1258
1260
  this.reset();
1259
1261
  return this;
@@ -2429,14 +2431,14 @@
2429
2431
  var BitState = class {
2430
2432
  constructor() {
2431
2433
  this.end = 0;
2432
- this.cap = new Int32Array(0);
2433
- this.matchcap = new Int32Array(0);
2434
+ this.cap = /* @__PURE__ */ new Int32Array(0);
2435
+ this.matchcap = /* @__PURE__ */ new Int32Array(0);
2434
2436
  this.ncap = 0;
2435
2437
  this.jobPc = new Int32Array(INITIAL_JOB_CAPACITY);
2436
2438
  this.jobArg = new Uint8Array(INITIAL_JOB_CAPACITY);
2437
2439
  this.jobPos = new Int32Array(INITIAL_JOB_CAPACITY);
2438
2440
  this.jobLen = 0;
2439
- this.visited = new Uint32Array(0);
2441
+ this.visited = /* @__PURE__ */ new Uint32Array(0);
2440
2442
  }
2441
2443
  reset(prog, end, ncap) {
2442
2444
  this.end = end;
@@ -3946,7 +3948,7 @@
3946
3948
  97,
3947
3949
  122
3948
3950
  ];
3949
- const PERL_GROUPS = new Map([
3951
+ const PERL_GROUPS = /* @__PURE__ */ new Map([
3950
3952
  ["\\d", new CharGroup(1, code1)],
3951
3953
  ["\\D", new CharGroup(-1, code1)],
3952
3954
  ["\\s", new CharGroup(1, code2)],
@@ -4020,7 +4022,7 @@
4020
4022
  97,
4021
4023
  102
4022
4024
  ];
4023
- const POSIX_GROUPS = new Map([
4025
+ const POSIX_GROUPS = /* @__PURE__ */ new Map([
4024
4026
  ["[:alnum:]", new CharGroup(1, code4)],
4025
4027
  ["[:^alnum:]", new CharGroup(-1, code4)],
4026
4028
  ["[:alpha:]", new CharGroup(1, code5)],
@@ -6367,6 +6369,33 @@
6367
6369
  return this.re2Input.executeEngine(machineInput, 0, RE2Flags.ANCHOR_BOTH, 0) !== null;
6368
6370
  }
6369
6371
  /**
6372
+ * Executes a search for a match in a specified string.
6373
+ * Returns a result array, or null if no match is found.
6374
+ * The returned array perfectly mirrors standard JavaScript `RegExpExecArray`,
6375
+ * including `.index`, `.input`, and `.groups` properties.
6376
+ *
6377
+ * @param {string|number[]|Uint8Array} input the input string or byte array
6378
+ * @returns {Array|null} the match array with index, input, and groups properties, or null
6379
+ */
6380
+ exec(input) {
6381
+ const m = this.matcher(input);
6382
+ if (!m.find()) return null;
6383
+ const result = [m.group(0)];
6384
+ for (let i = 1; i <= m.groupCount(); i++) {
6385
+ const val = m.group(i);
6386
+ result.push(val === null ? void 0 : val);
6387
+ }
6388
+ result.index = m.start(0);
6389
+ result.input = input;
6390
+ const namedGroups = this.namedGroups();
6391
+ if (Object.keys(namedGroups).length > 0) {
6392
+ const parsedGroups = m.getNamedGroups();
6393
+ for (const key in parsedGroups) if (parsedGroups[key] === null) parsedGroups[key] = void 0;
6394
+ result.groups = parsedGroups;
6395
+ } else result.groups = void 0;
6396
+ return result;
6397
+ }
6398
+ /**
6370
6399
  * Splits input around instances of the regular expression. It returns an array giving the strings
6371
6400
  * that occur before, between, and after instances of the regular expression.
6372
6401
  *
@@ -6418,7 +6447,7 @@
6418
6447
  * including capturing groups.
6419
6448
  *
6420
6449
  * @param {string|number[]|Uint8Array} input the input string or byte array
6421
- * @returns {IterableIterator<Array>}
6450
+ * @returns {IterableIterator<RegExpMatchArray>}
6422
6451
  */
6423
6452
  *matchAll(input) {
6424
6453
  const m = this.matcher(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "re2js",
3
- "version": "2.8.3",
3
+ "version": "2.8.5",
4
4
  "description": "RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -56,24 +56,24 @@
56
56
  },
57
57
  "devDependencies": {
58
58
  "@eslint/js": "^9.39.4",
59
- "@unicode/unicode-17.0.0": "^1.6.16",
60
- "@vitest/browser": "^4.1.6",
61
- "@vitest/browser-playwright": "^4.1.6",
62
- "@vitest/coverage-v8": "^4.1.6",
59
+ "@unicode/unicode-17.0.0": "^1.6.17",
60
+ "@vitest/browser": "^4.1.9",
61
+ "@vitest/browser-playwright": "^4.1.9",
62
+ "@vitest/coverage-v8": "^4.1.9",
63
63
  "@yarnpkg/pnpify": "^4.1.6",
64
64
  "dts-bundle-generator": "^9.5.1",
65
65
  "eslint": "9.39.4",
66
66
  "eslint-config-prettier": "^10.1.8",
67
- "eslint-import-resolver-node": "^0.3.10",
67
+ "eslint-import-resolver-node": "^0.4.0",
68
68
  "eslint-plugin-import": "^2.32.0",
69
- "globals": "^17.6.0",
69
+ "globals": "^17.7.0",
70
70
  "lodash": "^4.18.1",
71
- "playwright": "^1.60.0",
72
- "prettier": "^3.8.3",
73
- "rolldown": "^1.0.1",
71
+ "playwright": "^1.61.1",
72
+ "prettier": "^3.8.4",
73
+ "rolldown": "^1.1.3",
74
74
  "typescript": "^6.0.3",
75
75
  "unicode-property-value-aliases": "^3.9.0",
76
- "vitest": "^4.1.6"
76
+ "vitest": "^4.1.9"
77
77
  },
78
- "packageManager": "yarn@4.14.1"
78
+ "packageManager": "yarn@4.17.0"
79
79
  }