-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
217 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require('../../modules/es.symbol'); | ||
require('../../modules/esnext.symbol.is-registered-symbol'); | ||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.Symbol.isRegisteredSymbol; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require('../../modules/es.symbol'); | ||
require('../../modules/esnext.symbol.is-well-known-symbol'); | ||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.Symbol.isWellKnownSymbol; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
|
||
var Symbol = getBuiltIn('Symbol'); | ||
var keyFor = Symbol.keyFor; | ||
var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); | ||
|
||
// `Symbol.isRegisteredSymbol` method | ||
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregisteredsymbol | ||
module.exports = Symbol.isRegisteredSymbol || function isRegisteredSymbol(value) { | ||
try { | ||
return keyFor(thisSymbolValue(value)) !== undefined; | ||
} catch (error) { | ||
return false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var shared = require('../internals/shared'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var isSymbol = require('../internals/is-symbol'); | ||
var wellKnownSymbol = require('../internals/well-known-symbol'); | ||
|
||
var Symbol = getBuiltIn('Symbol'); | ||
var $isWellKnownSymbol = Symbol.isWellKnownSymbol; | ||
var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames'); | ||
var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); | ||
var WellKnownSymbolsStore = shared('wks'); | ||
|
||
for (var i = 0, symbolKeys = getOwnPropertyNames(Symbol), symbolKeysLength = symbolKeys.length; i < symbolKeysLength; i++) { | ||
// some old engines throws on access to some keys like `arguments` or `caller` | ||
try { | ||
var symbolKey = symbolKeys[i]; | ||
if (isSymbol(Symbol[symbolKey])) wellKnownSymbol(symbolKey); | ||
} catch (error) { /* empty */ } | ||
} | ||
|
||
// `Symbol.isWellKnownSymbol` method | ||
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol | ||
// We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected | ||
module.exports = function isWellKnownSymbol(value) { | ||
if ($isWellKnownSymbol && $isWellKnownSymbol(value)) return true; | ||
try { | ||
var symbol = thisSymbolValue(value); | ||
for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) { | ||
if (WellKnownSymbolsStore[keys[j]] == symbol) return true; | ||
} | ||
} catch (error) { /* empty */ } | ||
return false; | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/core-js/modules/esnext.symbol.is-registered-symbol.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var $ = require('../internals/export'); | ||
var isRegisteredSymbol = require('../internals/symbol-is-registered'); | ||
|
||
// `Symbol.isRegisteredSymbol` method | ||
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregisteredsymbol | ||
$({ target: 'Symbol', stat: true }, { | ||
isRegisteredSymbol: isRegisteredSymbol | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,8 @@ | ||
var $ = require('../internals/export'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
|
||
var Symbol = getBuiltIn('Symbol'); | ||
var keyFor = Symbol.keyFor; | ||
var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); | ||
var isRegisteredSymbol = require('../internals/symbol-is-registered'); | ||
|
||
// `Symbol.isRegistered` method | ||
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregistered | ||
$({ target: 'Symbol', stat: true }, { | ||
isRegistered: function isRegistered(value) { | ||
try { | ||
return keyFor(thisSymbolValue(value)) !== undefined; | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
// obsolete version of https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregisteredsymbol | ||
$({ target: 'Symbol', stat: true, name: 'isRegisteredSymbol' }, { | ||
isRegistered: isRegisteredSymbol | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/core-js/modules/esnext.symbol.is-well-known-symbol.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var $ = require('../internals/export'); | ||
var isWellKnownSymbol = require('../internals/symbol-is-well-known'); | ||
|
||
// `Symbol.isWellKnownSymbol` method | ||
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol | ||
// We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected | ||
$({ target: 'Symbol', stat: true, forced: true }, { | ||
isWellKnownSymbol: isWellKnownSymbol | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,9 @@ | ||
var $ = require('../internals/export'); | ||
var shared = require('../internals/shared'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var isSymbol = require('../internals/is-symbol'); | ||
var wellKnownSymbol = require('../internals/well-known-symbol'); | ||
|
||
var Symbol = getBuiltIn('Symbol'); | ||
var $isWellKnown = Symbol.isWellKnown; | ||
var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames'); | ||
var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); | ||
var WellKnownSymbolsStore = shared('wks'); | ||
|
||
for (var i = 0, symbolKeys = getOwnPropertyNames(Symbol), symbolKeysLength = symbolKeys.length; i < symbolKeysLength; i++) { | ||
// some old engines throws on access to some keys like `arguments` or `caller` | ||
try { | ||
var symbolKey = symbolKeys[i]; | ||
if (isSymbol(Symbol[symbolKey])) wellKnownSymbol(symbolKey); | ||
} catch (error) { /* empty */ } | ||
} | ||
var isWellKnownSymbol = require('../internals/symbol-is-well-known'); | ||
|
||
// `Symbol.isWellKnown` method | ||
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknown | ||
// obsolete version of https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol | ||
// We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected | ||
$({ target: 'Symbol', stat: true, forced: true }, { | ||
isWellKnown: function isWellKnown(value) { | ||
if ($isWellKnown && $isWellKnown(value)) return true; | ||
try { | ||
var symbol = thisSymbolValue(value); | ||
for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) { | ||
if (WellKnownSymbolsStore[keys[j]] == symbol) return true; | ||
} | ||
} catch (error) { /* empty */ } | ||
return false; | ||
} | ||
$({ target: 'Symbol', stat: true, name: 'isWellKnownSymbol', forced: true }, { | ||
isWellKnown: isWellKnownSymbol | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// https://github.com/tc39/proposal-symbol-predicates | ||
require('../modules/esnext.symbol.is-registered-symbol'); | ||
require('../modules/esnext.symbol.is-well-known-symbol'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
QUnit.test('Symbol.isRegisteredSymbol', assert => { | ||
const { isRegisteredSymbol } = Symbol; | ||
assert.isFunction(isRegisteredSymbol, 'Symbol.isRegisteredSymbol is function'); | ||
assert.nonEnumerable(Symbol, 'isRegisteredSymbol'); | ||
assert.arity(isRegisteredSymbol, 1, 'Symbol.isRegisteredSymbol arity is 1'); | ||
assert.name(isRegisteredSymbol, 'isRegisteredSymbol', 'Symbol.isRegisteredSymbol.name is "isRegisteredSymbol"'); | ||
assert.looksNative(isRegisteredSymbol, 'isRegisteredSymbol looks like native'); | ||
|
||
assert.true(isRegisteredSymbol(Symbol.for('foo')), 'registered-1'); | ||
assert.true(isRegisteredSymbol(Object(Symbol.for('foo'))), 'registered-2'); | ||
assert.false(isRegisteredSymbol(Symbol()), 'non-registered'); | ||
assert.false(isRegisteredSymbol(Object(Symbol())), 'non-registered'); | ||
assert.false(isRegisteredSymbol(1), '1'); | ||
assert.false(isRegisteredSymbol(true), 'true'); | ||
assert.false(isRegisteredSymbol('1'), 'string'); | ||
assert.false(isRegisteredSymbol(null), 'null'); | ||
assert.false(isRegisteredSymbol(), 'undefined'); | ||
assert.false(isRegisteredSymbol({}), 'object'); | ||
assert.false(isRegisteredSymbol([]), 'array'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
QUnit.test('Symbol.isWellKnownSymbol', assert => { | ||
const { isWellKnownSymbol } = Symbol; | ||
assert.isFunction(isWellKnownSymbol, 'Symbol.isWellKnownSymbol is function'); | ||
assert.nonEnumerable(Symbol, 'isWellKnownSymbol'); | ||
assert.arity(isWellKnownSymbol, 1, 'Symbol.isWellKnownSymbol arity is 1'); | ||
assert.name(isWellKnownSymbol, 'isWellKnownSymbol', 'Symbol.isWellKnownSymbol.name is "isWellKnownSymbol"'); | ||
assert.looksNative(isWellKnownSymbol, 'isWellKnownSymbol looks like native'); | ||
|
||
assert.true(isWellKnownSymbol(Symbol.iterator), 'registered-1'); | ||
assert.true(isWellKnownSymbol(Object(Symbol.iterator)), 'registered-2'); | ||
assert.true(isWellKnownSymbol(Symbol.patternMatch), 'registered-3'); | ||
assert.true(isWellKnownSymbol(Object(Symbol.patternMatch)), 'registered-4'); | ||
assert.false(isWellKnownSymbol(Symbol()), 'non-registered'); | ||
assert.false(isWellKnownSymbol(Object(Symbol())), 'non-registered'); | ||
assert.false(isWellKnownSymbol(1), '1'); | ||
assert.false(isWellKnownSymbol(true), 'true'); | ||
assert.false(isWellKnownSymbol('1'), 'string'); | ||
assert.false(isWellKnownSymbol(null), 'null'); | ||
assert.false(isWellKnownSymbol(), 'undefined'); | ||
assert.false(isWellKnownSymbol({}), 'object'); | ||
assert.false(isWellKnownSymbol([]), 'array'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Symbol from 'core-js-pure/full/symbol'; | ||
|
||
QUnit.test('Symbol.isRegisteredSymbol', assert => { | ||
const { isRegisteredSymbol } = Symbol; | ||
assert.isFunction(isRegisteredSymbol, 'Symbol.isRegisteredSymbol is function'); | ||
assert.arity(isRegisteredSymbol, 1, 'Symbol.isRegisteredSymbol arity is 1'); | ||
assert.name(isRegisteredSymbol, 'isRegisteredSymbol', 'Symbol.isRegisteredSymbol.name is "isRegisteredSymbol"'); | ||
|
||
assert.true(isRegisteredSymbol(Symbol.for('foo')), 'registered-1'); | ||
assert.true(isRegisteredSymbol(Object(Symbol.for('foo'))), 'registered-2'); | ||
assert.false(isRegisteredSymbol(Symbol()), 'non-registered'); | ||
assert.false(isRegisteredSymbol(Object(Symbol())), 'non-registered'); | ||
assert.false(isRegisteredSymbol(1), '1'); | ||
assert.false(isRegisteredSymbol(true), 'true'); | ||
assert.false(isRegisteredSymbol('1'), 'string'); | ||
assert.false(isRegisteredSymbol(null), 'null'); | ||
assert.false(isRegisteredSymbol(), 'undefined'); | ||
assert.false(isRegisteredSymbol({}), 'object'); | ||
assert.false(isRegisteredSymbol([]), 'array'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.