Skip to content

Commit 8957db1

Browse files
committed
update pattern matching proposal
1 parent 212ff8a commit 8957db1

File tree

14 files changed

+60
-11
lines changed

14 files changed

+60
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
- [`RegExp.escape` stage 2 proposal](https://github.com/tc39/proposal-regex-escaping)
2525
- Moved to hex-escape semantics, [regex-escaping/67](https://github.com/tc39/proposal-regex-escaping/pull/67)
2626
- It's not the final change of the way of escaping, waiting for [regex-escaping/77](https://github.com/tc39/proposal-regex-escaping/pull/77) soon
27+
- [Pattern matching proposal](https://github.com/tc39/proposal-pattern-matching):
28+
- Built-ins:
29+
- `Symbol.customMatcher`
30+
- Once again, [the used well-known symbol was renamed](https://github.com/tc39/proposal-pattern-matching/pull/295)
31+
- Added new entries for that
2732
- Added [`URL.parse`](https://url.spec.whatwg.org/#dom-url-parse), [url/825](https://github.com/whatwg/url/pull/825)
2833
- Engines bugs fixes:
2934
- Added a fix of [Safari `{ Object, Map }.groupBy` bug that does not support iterable primitives](https://bugs.webkit.org/show_bug.cgi?id=271524)

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
185185
- [`Number.fromString`](#numberfromstring)
186186
- [`String.cooked`](#stringcooked)
187187
- [`String.prototype.codePoints`](#stringprototypecodepoints)
188-
- [`Symbol.matcher` for pattern matching](#symbolmatcher-for-pattern-matching)
188+
- [`Symbol.customMatcher` for pattern matching](#symbolcustommatcher-for-pattern-matching)
189189
- [Stage 0 proposals](#stage-0-proposals)
190190
- [`Function.prototype.demethodize`](#functionprototypedemethodize)
191191
- [`Function.{ isCallable, isConstructor }`](#function-iscallable-isconstructor-)
@@ -2759,6 +2759,7 @@ Symbol.isRegisteredSymbol(Symbol('key')); // => false
27592759
Symbol.isWellKnownSymbol(Symbol.iterator); // => true
27602760
Symbol.isWellKnownSymbol(Symbol('key')); // => false
27612761
```
2762+
27622763
##### [`Uint8Array` to / from base64 and hex](https://github.com/tc39/proposal-arraybuffer-base64)[⬆](#index)
27632764
Modules [`esnext.uint8-array.from-base64`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.from-base64.js), [`esnext.uint8-array.from-hex`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.from-hex.js), [`esnext.uint8-array.to-base64`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.to-base64.js), [`esnext.uint8-array.to-hex`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.to-hex.js).
27642765
```js
@@ -3083,17 +3084,18 @@ for (let { codePoint, position } of 'qwe'.codePoints()) {
30833084
console.log(position); // => 0, 1, 2
30843085
}
30853086
```
3086-
##### [`Symbol.matcher` for pattern matching](https://github.com/tc39/proposal-pattern-matching)[⬆](#index)
3087-
Module [`esnext.symbol.matcher`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.matcher.js).
3087+
3088+
##### [`Symbol.customMatcher` for pattern matching](https://github.com/tc39/proposal-pattern-matching)[⬆](#index)
3089+
Module [`esnext.symbol.custom-matcher`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.custom-matcher.js).
30883090
```js
30893091
class Symbol {
3090-
static matcher: @@matcher;
3092+
static customMatcher: @@customMatcher;
30913093
}
30923094
```
30933095
[*CommonJS entry points:*](#commonjs-api)
30943096
```js
3095-
core-js/proposals/pattern-matching
3096-
core-js(-pure)/full/symbol/matcher
3097+
core-js/proposals/pattern-matching-v2
3098+
core-js(-pure)/full/symbol/custom-matcher
30973099
```
30983100

30993101
#### Stage 0 proposals[⬆](#index)

packages/core-js-compat/src/data.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,8 @@ export const data = {
24092409
// https://github.com/nodejs/node/issues/48699
24102410
node: '20.5.0',
24112411
},
2412+
'esnext.symbol.custom-matcher': {
2413+
},
24122414
'esnext.symbol.dispose': {
24132415
bun: '1.0.23',
24142416
deno: '1.38',
@@ -2427,6 +2429,7 @@ export const data = {
24272429
// TODO: Remove from `core-js@4`
24282430
'esnext.symbol.is-well-known': {
24292431
},
2432+
// TODO: Remove from `core-js@4`
24302433
'esnext.symbol.matcher': {
24312434
},
24322435
'esnext.symbol.metadata': {

packages/core-js-compat/src/modules-by-versions.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export default {
246246
'es.set.symmetric-difference.v2',
247247
'es.set.union.v2',
248248
'esnext.math.sum-precise',
249+
'esnext.symbol.custom-matcher',
249250
'web.url.parse',
250251
],
251252
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
require('../../modules/esnext.symbol.custom-matcher');
3+
var WrappedWellKnownSymbolModule = require('../../internals/well-known-symbol-wrapped');
4+
5+
module.exports = WrappedWellKnownSymbolModule.f('customMatcher');

packages/core-js/full/symbol/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
var parent = require('../../actual/symbol');
33
require('../../modules/esnext.symbol.is-registered-symbol');
44
require('../../modules/esnext.symbol.is-well-known-symbol');
5-
require('../../modules/esnext.symbol.matcher');
5+
require('../../modules/esnext.symbol.custom-matcher');
66
require('../../modules/esnext.symbol.observable');
77
// TODO: Remove from `core-js@4`
88
require('../../modules/esnext.symbol.is-registered');
99
require('../../modules/esnext.symbol.is-well-known');
10+
require('../../modules/esnext.symbol.matcher');
1011
require('../../modules/esnext.symbol.metadata-key');
1112
require('../../modules/esnext.symbol.pattern-match');
1213
require('../../modules/esnext.symbol.replace-all');
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
var defineWellKnownSymbol = require('../internals/well-known-symbol-define');
3+
4+
// `Symbol.customMatcher` well-known symbol
5+
// https://github.com/tc39/proposal-pattern-matching
6+
defineWellKnownSymbol('customMatcher');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
// https://github.com/tc39/proposal-pattern-matching
3+
require('../modules/esnext.symbol.custom-matcher');

packages/core-js/stage/1.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ require('../proposals/math-signbit');
1313
require('../proposals/number-from-string');
1414
require('../proposals/object-iteration');
1515
require('../proposals/observable');
16-
require('../proposals/pattern-matching');
16+
require('../proposals/pattern-matching-v2');
1717
require('../proposals/seeded-random');
1818
require('../proposals/string-code-points');
1919
require('../proposals/string-cooked');
2020
// TODO: Obsolete versions, remove from `core-js@4`:
2121
require('../proposals/array-from-async');
2222
require('../proposals/map-upsert');
2323
require('../proposals/number-range');
24+
require('../proposals/pattern-matching');
2425
require('../proposals/string-replace-all');
2526

2627
module.exports = parent;

tests/compat-data/tests-coverage.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const ignore = new Set([
6464
'esnext.string.at',
6565
'esnext.symbol.is-registered',
6666
'esnext.symbol.is-well-known',
67+
'esnext.symbol.matcher',
6768
'esnext.symbol.metadata-key',
6869
'esnext.symbol.pattern-match',
6970
'esnext.symbol.replace-all',

0 commit comments

Comments
 (0)