Skip to content

Commit 98e421f

Browse files
committed
add Symbol.metadata
1 parent f498ee5 commit 98e421f

File tree

13 files changed

+55
-1
lines changed

13 files changed

+55
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,18 @@ Object.hasOwn({ foo: 42 }, 'foo'); // => true
20492049
Object.hasOwn({ foo: 42 }, 'bar'); // => false
20502050
Object.hasOwn({}, 'toString'); // => false
20512051
````
2052+
##### [`Symbol.metadata` for decorators proposal](https://github.com/tc39/proposal-decorators)[⬆](#index)
2053+
Module [`esnext.symbol.metadata`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.metadata.js).
2054+
```js
2055+
class Symbol {
2056+
static metadata: @@metadata;
2057+
}
2058+
```
2059+
[*CommonJS entry points:*](#commonjs-api)
2060+
```js
2061+
core-js/proposals/decorators
2062+
core-js(-pure)/features/symbol/metadata
2063+
```
20522064
20532065
#### Stage 1 proposals[⬆](#index)
20542066
[*CommonJS entry points:*](#commonjs-api)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,8 @@ const data = {
15041504
},
15051505
'esnext.symbol.dispose': {
15061506
},
1507+
'esnext.symbol.metadata': {
1508+
},
15071509
'esnext.symbol.observable': {
15081510
},
15091511
'esnext.symbol.pattern-match': {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,7 @@ module.exports = {
8383
3.11: [
8484
'esnext.object.has-own',
8585
],
86+
3.12: [
87+
'esnext.symbol.metadata',
88+
],
8689
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var parent = require('../../es/symbol');
22
require('../../modules/esnext.symbol.async-dispose');
33
require('../../modules/esnext.symbol.dispose');
4+
require('../../modules/esnext.symbol.metadata');
45
require('../../modules/esnext.symbol.observable');
56
require('../../modules/esnext.symbol.pattern-match');
67
// TODO: Remove from `core-js@4`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
require('../../modules/esnext.symbol.metadata');
2+
var WrappedWellKnownSymbolModule = require('../../internals/well-known-symbol-wrapped');
3+
4+
module.exports = WrappedWellKnownSymbolModule.f('metadata');
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.metadata` well-known symbol
4+
// https://github.com/tc39/proposal-decorators
5+
defineWellKnownSymbol('metadata');
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// https://github.com/tc39/proposal-decorators
2+
require('../modules/esnext.symbol.metadata');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// https://github.com/tc39/proposal-pattern-matching
12
require('../modules/esnext.symbol.pattern-match');

packages/core-js/stage/2.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require('../proposals/accessible-object-hasownproperty');
22
require('../proposals/array-find-from-last');
33
require('../proposals/array-is-template-object');
4+
require('../proposals/decorators');
45
require('../proposals/iterator-helpers');
56
require('../proposals/map-upsert');
67
require('../proposals/set-methods');

tests/commonjs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ for (PATH of ['core-js-pure', 'core-js']) {
5555
}, 1, 2)(3) === 6);
5656
load('features/function/name');
5757
load('features/function/has-instance');
58-
ok(Function[load('features/symbol/has-instance')](it => it));
5958
ok('bind' in load('features/function'));
6059
ok(load('features/array/is-array')([]));
6160
ok(typeof load('features/array/is-template-object') === 'function');
@@ -299,6 +298,7 @@ for (PATH of ['core-js-pure', 'core-js']) {
299298
ok(load('features/symbol/iterator'));
300299
ok(load('features/symbol/match'));
301300
ok(load('features/symbol/match-all'));
301+
ok(load('features/symbol/metadata'));
302302
ok(load('features/symbol/replace'));
303303
ok(load('features/symbol/search'));
304304
ok(load('features/symbol/species'));
@@ -972,6 +972,7 @@ for (PATH of ['core-js-pure', 'core-js']) {
972972
load('proposals/array-unique');
973973
load('proposals/collection-methods');
974974
load('proposals/collection-of-from');
975+
load('proposals/decorators');
975976
load('proposals/efficient-64-bit-arithmetic');
976977
load('proposals/global-this');
977978
load('proposals/iterator-helpers');

tests/compat/tests.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,9 @@ GLOBAL.tests = {
14311431
'esnext.symbol.dispose': function () {
14321432
return Symbol.dispose;
14331433
},
1434+
'esnext.symbol.metadata': function () {
1435+
return Symbol.metadata;
1436+
},
14341437
'esnext.symbol.observable': function () {
14351438
return Symbol.observable;
14361439
},

tests/pure/esnext.symbol.metadata.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.metadata', assert => {
4+
assert.ok('metadata' in Symbol, 'Symbol.metadata available');
5+
assert.ok(Object(Symbol.metadata) instanceof Symbol, 'Symbol.metadata is symbol');
6+
});

tests/tests/esnext.symbol.metadata.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.metadata', assert => {
4+
assert.ok('metadata' in Symbol, 'Symbol.metadata available');
5+
assert.nonEnumerable(Symbol, 'metadata');
6+
assert.ok(Object(Symbol.metadata) instanceof Symbol, 'Symbol.metadata is symbol');
7+
if (DESCRIPTORS) {
8+
const descriptor = Object.getOwnPropertyDescriptor(Symbol, 'metadata');
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)