re2js 2.3.0 → 2.3.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 CHANGED
@@ -562,8 +562,7 @@ console.log(RE2JS.compile('(a+b?)').programSize()); // Outputs: 8
562
562
 
563
563
  ### Translating Regular Expressions
564
564
 
565
- The `translateRegExp()` method preprocesses a given regular expression string to ensure compatibility with RE2JS.
566
- It applies necessary transformations, such as escaping special characters, adjusting Unicode sequences, and converting named capture groups
565
+ The `translateRegExp()` method preprocesses a given regular expression string or native RegExp object to ensure compatibility with RE2JS. It applies necessary transformations, such as escaping special characters, adjusting Unicode sequences, converting named capture groups, and mapping native execution flags
567
566
 
568
567
  ```js
569
568
  import { RE2JS } from 're2js'
@@ -579,7 +578,11 @@ RE2JS.matches(unicodeRegexp, '😀') // true
579
578
  RE2JS.matches(unicodeRegexp, '😃') // false
580
579
 
581
580
  // also support native Regex
582
- RE2JS.translateRegExp(/foo/ims) // '(?ims)foo'
581
+ const translatedNative = RE2JS.translateRegExp(/foo/ims) // '(?ims)foo'
582
+
583
+ const re = RE2JS.compile(translatedNative)
584
+ re.test('FOO') // true
585
+
583
586
  RE2JS.translateRegExp(/bar/giy) // '(?i)bar'
584
587
  ```
585
588
 
@@ -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.3.0
5
+ * @version v2.3.1
6
6
  * @author Oleksii Vasyliev
7
7
  * @homepage https://github.com/le0pard/re2js#readme
8
8
  * @repository github:le0pard/re2js
@@ -1332,10 +1332,6 @@ class RE2JSInternalException extends RE2JSException {
1332
1332
  * @author rsc@google.com (Russ Cox)
1333
1333
  */
1334
1334
 
1335
- /**
1336
- * @typedef {import('./index').RE2JS} RE2JS_Pattern
1337
- */
1338
-
1339
1335
  class Matcher {
1340
1336
  /**
1341
1337
  * Quotes '\' and '$' in {@code s}, so that the returned string could be used in
@@ -1373,8 +1369,8 @@ class Matcher {
1373
1369
  }
1374
1370
  /**
1375
1371
  *
1376
- * @param {RE2JS_Pattern} pattern
1377
- * @param {Uint8Array|number[]|string} input
1372
+ * @param {RE2JS} pattern
1373
+ * @param {string|number[]|Uint8Array} input
1378
1374
  */
1379
1375
  constructor(pattern, input) {
1380
1376
  if (pattern === null) {
@@ -1382,7 +1378,7 @@ class Matcher {
1382
1378
  }
1383
1379
  /**
1384
1380
  * The pattern being matched.
1385
- * @type {RE2JS_Pattern}
1381
+ * @type {RE2JS}
1386
1382
  */
1387
1383
  this.patternInput = pattern;
1388
1384
  const re2 = this.patternInput.re2();
@@ -1407,7 +1403,7 @@ class Matcher {
1407
1403
 
1408
1404
  /**
1409
1405
  * Returns the {@code RE2JS} associated with this {@code Matcher}.
1410
- * @returns {RE2JS_Pattern}
1406
+ * @returns {RE2JS}
1411
1407
  */
1412
1408
  pattern() {
1413
1409
  return this.patternInput;
@@ -1437,7 +1433,7 @@ class Matcher {
1437
1433
 
1438
1434
  /**
1439
1435
  * Resets the {@code Matcher} and changes the input.
1440
- * @param {import('./MatcherInput').MatcherInputBase} input
1436
+ * @param {MatcherInputBase} input
1441
1437
  * @returns {Matcher} the {@code Matcher} itself, for chained method calls
1442
1438
  */
1443
1439
  resetMatcherInput(input) {