Skip to content

Commit 0ec0aeb

Browse files
authored
Update README.md
We no longer auto-install a matcher in `class{}` blocks, the Function.prototype matcher just does things correctly.
1 parent 7e23756 commit 0ec0aeb

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

README.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ There are several types of value patterns, performing different types of tests.
183183

184184
### Primitive Patterns
185185

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,
187187
representing a test that the subject matches the specified value,
188188
using [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) semantics
189189
(except when otherwise noted).
@@ -367,23 +367,6 @@ RegExp.prototype[Symbol.customMatcher] = function(subject, {matchType}) {
367367
}
368368
```
369369

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-
387370

388371
### Regex Patterns
389372

0 commit comments

Comments
 (0)