re2js 2.5.0 → 2.6.0

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 v2.5.0
5
+ * @version v2.6.0
6
6
  * @author Oleksii Vasyliev
7
7
  * @homepage https://github.com/le0pard/re2js#readme
8
8
  * @repository github:le0pard/re2js
@@ -8658,6 +8658,47 @@
8658
8658
  return result;
8659
8659
  }
8660
8660
 
8661
+ /**
8662
+ * Returns an iterator of all results matching a string against the regular expression,
8663
+ * including capturing groups.
8664
+ *
8665
+ * @param {string|number[]|Uint8Array} input the input string or byte array
8666
+ * @returns {IterableIterator<Array>}
8667
+ */
8668
+ *matchAll(input) {
8669
+ const m = this.matcher(input);
8670
+ const inputStr = typeof input === 'string' ? input : m.matcherInput.asCharSequence();
8671
+ while (m.find()) {
8672
+ // Build the match array starting with the full match
8673
+ const result = [m.group(0)];
8674
+
8675
+ // Append all capture groups using void 0 instead of undefined
8676
+ for (let i = 1; i <= m.groupCount(); i++) {
8677
+ const groupVal = m.group(i);
8678
+ result.push(groupVal === null ? void 0 : groupVal);
8679
+ }
8680
+
8681
+ // Attach native RegExp match properties
8682
+ result.index = m.start(0);
8683
+ result.input = inputStr;
8684
+
8685
+ // Attach named capture groups if they exist
8686
+ const namedGroups = this.namedGroups();
8687
+ if (Object.keys(namedGroups).length > 0) {
8688
+ const parsedGroups = m.getNamedGroups();
8689
+ for (const key in parsedGroups) {
8690
+ if (parsedGroups[key] === null) {
8691
+ parsedGroups[key] = void 0;
8692
+ }
8693
+ }
8694
+ result.groups = parsedGroups;
8695
+ } else {
8696
+ result.groups = void 0;
8697
+ }
8698
+ yield result;
8699
+ }
8700
+ }
8701
+
8661
8702
  /**
8662
8703
  *
8663
8704
  * @returns {string}
@@ -8714,6 +8755,8 @@
8714
8755
  return this.flagsInput === other.flagsInput && this.patternInput === other.patternInput;
8715
8756
  }
8716
8757
  }
8758
+
8759
+ /* Small helper for Tagged Template Literals (No Double-Escaping) */
8717
8760
  const re = (stringsOrFlags, ...values) => {
8718
8761
  if (Array.isArray(stringsOrFlags) && stringsOrFlags.raw) {
8719
8762
  const pattern = String.raw(stringsOrFlags, ...values);