re2js 1.2.3 → 1.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
@@ -161,6 +161,40 @@ matchString.group() // 'e'
161
161
  matchString.find(7) // false
162
162
  ```
163
163
 
164
+ ### High-Performance Boolean Testing
165
+
166
+ If you only need to know **whether** a string matches a pattern (without extracting capture groups), you should use the `test()` and `testExact()` methods. Unlike `matches()` or `matcher()`, these methods do not instantiate stateful `Matcher` objects and request exactly `0` capture groups. This guarantees that execution is securely routed to the DFA (Deterministic Finite Automaton) engine whenever possible
167
+
168
+ #### `test(input)`
169
+
170
+ Tests if the regular expression matches **any part** of the provided input (unanchored). This method mirrors the standard JavaScript `RegExp.prototype.test()` API
171
+
172
+ ```js
173
+ import { RE2JS } from 're2js';
174
+
175
+ // Compile once, reuse often
176
+ const re = RE2JS.compile('error|warning|critical');
177
+
178
+ // Extremely fast, unanchored DFA search
179
+ if (re.test('The system encountered a critical failure')) {
180
+ console.log('Log needs attention!');
181
+ }
182
+ ```
183
+
184
+ #### `testExact(input)`
185
+
186
+ Tests if the regular expression matches the entire input string (anchored to both start and end)
187
+
188
+ ```js
189
+ import { RE2JS } from 're2js';
190
+
191
+ const isHex = RE2JS.compile('[0-9A-Fa-f]+');
192
+
193
+ // Fast, anchored DFA validation
194
+ console.log(isHex.testExact('1A4F')); // true
195
+ console.log(isHex.testExact('1A4F-xyz')); // false
196
+ ```
197
+
164
198
  ### Checking Initial Match
165
199
 
166
200
  The `lookingAt()` method determines whether the start of the given string matches the pattern