re2js 2.5.0 → 2.6.1
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 +38 -11
- package/build/index.cjs.cjs +43 -1
- package/build/index.cjs.cjs.map +1 -1
- package/build/index.esm.d.ts +8 -0
- package/build/index.esm.d.ts.map +1 -1
- package/build/index.esm.js +43 -1
- package/build/index.esm.js.map +1 -1
- package/build/index.umd.js +43 -1
- package/build/index.umd.js.map +1 -1
- package/package.json +13 -8
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 v2.
|
|
5
|
+
* @version v2.6.1
|
|
6
6
|
* @author Oleksii Vasyliev
|
|
7
7
|
* @homepage https://github.com/le0pard/re2js#readme
|
|
8
8
|
* @repository github:le0pard/re2js
|
|
@@ -8658,6 +8658,46 @@
|
|
|
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
|
+
while (m.find()) {
|
|
8671
|
+
// Build the match array starting with the full match
|
|
8672
|
+
const result = [m.group(0)];
|
|
8673
|
+
|
|
8674
|
+
// Append all capture groups using void 0 instead of undefined
|
|
8675
|
+
for (let i = 1; i <= m.groupCount(); i++) {
|
|
8676
|
+
const groupVal = m.group(i);
|
|
8677
|
+
result.push(groupVal === null ? void 0 : groupVal);
|
|
8678
|
+
}
|
|
8679
|
+
|
|
8680
|
+
// Attach native RegExp match properties
|
|
8681
|
+
result.index = m.start(0);
|
|
8682
|
+
result.input = input; // Retains original String or Uint8Array so index aligns perfectly
|
|
8683
|
+
|
|
8684
|
+
// Attach named capture groups if they exist
|
|
8685
|
+
const namedGroups = this.namedGroups();
|
|
8686
|
+
if (Object.keys(namedGroups).length > 0) {
|
|
8687
|
+
const parsedGroups = m.getNamedGroups();
|
|
8688
|
+
for (const key in parsedGroups) {
|
|
8689
|
+
if (parsedGroups[key] === null) {
|
|
8690
|
+
parsedGroups[key] = void 0;
|
|
8691
|
+
}
|
|
8692
|
+
}
|
|
8693
|
+
result.groups = parsedGroups;
|
|
8694
|
+
} else {
|
|
8695
|
+
result.groups = void 0;
|
|
8696
|
+
}
|
|
8697
|
+
yield result;
|
|
8698
|
+
}
|
|
8699
|
+
}
|
|
8700
|
+
|
|
8661
8701
|
/**
|
|
8662
8702
|
*
|
|
8663
8703
|
* @returns {string}
|
|
@@ -8714,6 +8754,8 @@
|
|
|
8714
8754
|
return this.flagsInput === other.flagsInput && this.patternInput === other.patternInput;
|
|
8715
8755
|
}
|
|
8716
8756
|
}
|
|
8757
|
+
|
|
8758
|
+
/* Small helper for Tagged Template Literals (No Double-Escaping) */
|
|
8717
8759
|
const re = (stringsOrFlags, ...values) => {
|
|
8718
8760
|
if (Array.isArray(stringsOrFlags) && stringsOrFlags.raw) {
|
|
8719
8761
|
const pattern = String.raw(stringsOrFlags, ...values);
|