Skip to content

Commit b3afb28

Browse files
committed
add Symbol.matcher
1 parent 98e421f commit b3afb28

13 files changed

+46
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,8 +2400,8 @@ for (let x of Math.seededPRNG({ seed: 42 })) {
24002400
if (x > .8) break;
24012401
}
24022402
```
2403-
##### [`Symbol.patternMatch` for pattern matching](https://github.com/tc39/proposal-pattern-matching)[⬆](#index)
2404-
Module [`esnext.symbol.pattern-match`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.pattern-match.js).
2403+
##### [`Symbol.matcher` for pattern matching](https://github.com/tc39/proposal-pattern-matching)[⬆](#index)
2404+
Module [`esnext.symbol.matcher`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.matcher.js).
24052405
```js
24062406
class Symbol {
24072407
static patternMatch: @@patternMatch;
@@ -2410,7 +2410,7 @@ class Symbol {
24102410
[*CommonJS entry points:*](#commonjs-api)
24112411
```js
24122412
core-js/proposals/pattern-matching
2413-
core-js(-pure)/features/symbol/pattern-match
2413+
core-js(-pure)/features/symbol/matcher
24142414
```
24152415
##### [Object iteration](https://github.com/tc39/proposal-object-iteration)[⬆](#index)
24162416
Modules [`esnext.object.iterate-keys`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.object.iterate-keys.js), [`esnext.object.iterate-values`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.object.iterate-values.js), [`esnext.object.iterate-entries`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.object.iterate-entries.js).

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,10 +1504,13 @@ const data = {
15041504
},
15051505
'esnext.symbol.dispose': {
15061506
},
1507+
'esnext.symbol.matcher': {
1508+
},
15071509
'esnext.symbol.metadata': {
15081510
},
15091511
'esnext.symbol.observable': {
15101512
},
1513+
// TODO: Remove from `core-js@4`
15111514
'esnext.symbol.pattern-match': {
15121515
},
15131516
// TODO: Remove from `core-js@4`

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ module.exports = {
8484
'esnext.object.has-own',
8585
],
8686
3.12: [
87+
'esnext.symbol.matcher',
8788
'esnext.symbol.metadata',
8889
],
8990
};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
var parent = require('../../es/symbol');
22
require('../../modules/esnext.symbol.async-dispose');
33
require('../../modules/esnext.symbol.dispose');
4+
require('../../modules/esnext.symbol.matcher');
45
require('../../modules/esnext.symbol.metadata');
56
require('../../modules/esnext.symbol.observable');
7+
// TODO: Remove from `core-js@4`
68
require('../../modules/esnext.symbol.pattern-match');
79
// TODO: Remove from `core-js@4`
810
require('../../modules/esnext.symbol.replace-all');
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
require('../../modules/esnext.symbol.matcher');
2+
var WrappedWellKnownSymbolModule = require('../../internals/well-known-symbol-wrapped');
3+
4+
module.exports = WrappedWellKnownSymbolModule.f('matcher');

packages/core-js/features/symbol/pattern-match.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// TODO: Remove from `core-js@4`
12
require('../../modules/esnext.symbol.pattern-match');
23
var WrappedWellKnownSymbolModule = require('../../internals/well-known-symbol-wrapped');
34

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
2+
3+
// `Symbol.matcher` well-known symbol
4+
// https://github.com/tc39/proposal-pattern-matching
5+
defineWellKnownSymbol('matcher');

packages/core-js/modules/esnext.symbol.pattern-match.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// TODO: remove from `core-js@4`
12
var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
23

34
// `Symbol.patternMatch` well-known symbol
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
// https://github.com/tc39/proposal-pattern-matching
2+
require('../modules/esnext.symbol.matcher');
3+
// TODO: remove from `core-js@4`
24
require('../modules/esnext.symbol.pattern-match');

tests/commonjs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ for (PATH of ['core-js-pure', 'core-js']) {
297297
ok(load('features/symbol/is-concat-spreadable'));
298298
ok(load('features/symbol/iterator'));
299299
ok(load('features/symbol/match'));
300+
ok(load('features/symbol/matcher'));
300301
ok(load('features/symbol/match-all'));
301302
ok(load('features/symbol/metadata'));
302303
ok(load('features/symbol/replace'));

tests/compat/tests.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,12 +1431,16 @@ GLOBAL.tests = {
14311431
'esnext.symbol.dispose': function () {
14321432
return Symbol.dispose;
14331433
},
1434+
'esnext.symbol.matcher': function () {
1435+
return Symbol.matcher;
1436+
},
14341437
'esnext.symbol.metadata': function () {
14351438
return Symbol.metadata;
14361439
},
14371440
'esnext.symbol.observable': function () {
14381441
return Symbol.observable;
14391442
},
1443+
// TODO: Remove from `core-js@4`
14401444
'esnext.symbol.pattern-match': function () {
14411445
return Symbol.patternMatch;
14421446
},

tests/pure/esnext.symbol.matcher.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Symbol from 'core-js-pure/features/symbol';
2+
3+
QUnit.test('Symbol.matcher', assert => {
4+
assert.ok('matcher' in Symbol, 'Symbol.matcher available');
5+
assert.ok(Object(Symbol.matcher) instanceof Symbol, 'Symbol.matcher is symbol');
6+
});

tests/tests/esnext.symbol.matcher.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { DESCRIPTORS } from '../helpers/constants';
2+
3+
QUnit.test('Symbol.matcher', assert => {
4+
assert.ok('matcher' in Symbol, 'Symbol.matcher available');
5+
assert.nonEnumerable(Symbol, 'matcher');
6+
assert.ok(Object(Symbol.matcher) instanceof Symbol, 'Symbol.matcher is symbol');
7+
if (DESCRIPTORS) {
8+
const descriptor = Object.getOwnPropertyDescriptor(Symbol, 'matcher');
9+
assert.ok(!descriptor.enumerble, 'non-enumerable');
10+
assert.ok(!descriptor.writable, 'non-writable');
11+
assert.ok(!descriptor.configurable, 'non-configurable');
12+
}
13+
});

0 commit comments

Comments
 (0)