@@ -183,7 +183,7 @@ There are several types of value patterns, performing different types of tests.
183
183
184
184
### Primitive Patterns
185
185
186
- All primitive values and variable names can be used directly as matcher patterns,
186
+ All primitive values can be used directly as matcher patterns,
187
187
representing a test that the subject matches the specified value,
188
188
using [ ` SameValue ` ] ( https://tc39.es/ecma262/#sec-samevalue ) semantics
189
189
(except when otherwise noted).
@@ -367,23 +367,6 @@ RegExp.prototype[Symbol.customMatcher] = function(subject, {matchType}) {
367
367
}
368
368
```
369
369
370
- Note: We have two conflicting desires here:
371
- (1) allow predicate functions to be used as custom matchers in a trivial way, and
372
- (2) allow classes to be used as matchers in a trivial way.
373
- The only way to do (1) is to put a custom matcher on ` Function.prototype `
374
- that invokes the function for you,
375
- but this is * also* the only * normal* way to do (2),
376
- since ` Function.prototype ` is the nearest common prototype to all classes
377
- (save those that explicitly null out their prototype, of course).
378
- The solution we hit on here --
379
- having the ` class{} ` syntax install a default matcher if there's not one present --
380
- mirrors the behavior of constructor methods,
381
- and lets us have both behaviors cleanly.
382
- However, if this is deemed unacceptable,
383
- we could pursue other approaches,
384
- like having a prefix keyword to indicate a "boolean predicate pattern"
385
- so we can tell it apart from a custom matcher pattern.
386
-
387
370
388
371
### Regex Patterns
389
372
0 commit comments