es6-symbol
Advanced tools
Comparing version 3.0.1 to 3.0.2
{ | ||
"name": "es6-symbol", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "ECMAScript 6 Symbol polyfill", | ||
@@ -22,3 +22,3 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", | ||
"d": "~0.1.1", | ||
"es5-ext": "~0.10.8" | ||
"es5-ext": "~0.10.10" | ||
}, | ||
@@ -25,0 +25,0 @@ "devDependencies": { |
@@ -0,1 +1,3 @@ | ||
// ES2015 Symbol polyfill for environments that do not support it (or partially support it_ | ||
'use strict'; | ||
@@ -34,2 +36,4 @@ | ||
// Internal constructor (not one exposed) for creating Symbol instances. | ||
// This one is used to ensure that `someSymbol instanceof Symbol` always return false | ||
HiddenSymbol = function Symbol(description) { | ||
@@ -39,2 +43,5 @@ if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor'); | ||
}; | ||
// Exposed `Symbol` constructor | ||
// (returns instances of HiddenSymbol) | ||
module.exports = SymbolPolyfill = function Symbol(description) { | ||
@@ -60,2 +67,5 @@ var symbol; | ||
}), | ||
// If there's native implementation of given symbol, let's fallback to it | ||
// to ensure proper interoperability with other native functions e.g. Array.from | ||
hasInstance: d('', (NativeSymbol && NativeSymbol.hasInstance) || SymbolPolyfill('hasInstance')), | ||
@@ -74,2 +84,4 @@ isConcatSpreadable: d('', (NativeSymbol && NativeSymbol.isConcatSpreadable) || | ||
}); | ||
// Internal tweaks for real symbol producer | ||
defineProperties(HiddenSymbol.prototype, { | ||
@@ -80,2 +92,4 @@ constructor: d(SymbolPolyfill), | ||
// Proper implementation of methods exposed on Symbol.prototype | ||
// They won't be accessible on produced symbol instances as they derive from HiddenSymbol.prototype | ||
defineProperties(SymbolPolyfill.prototype, { | ||
@@ -89,5 +103,11 @@ toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), | ||
// Proper implementaton of toPrimitive and toStringTag for returned symbol instances | ||
defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toStringTag, | ||
d('c', SymbolPolyfill.prototype[SymbolPolyfill.toStringTag])); | ||
// Note: It's important to define `toPrimitive` as last one, as some implementations | ||
// implement `toPrimitive` natively without implementing `toStringTag` (or other specified symbols) | ||
// And that may invoke error in definition flow: | ||
// See: https://github.com/medikoo/es6-symbol/issues/13#issuecomment-164146149 | ||
defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toPrimitive, | ||
d('c', SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive])); | ||
defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toStringTag, | ||
d('c', SymbolPolyfill.prototype[SymbolPolyfill.toStringTag])); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14868
212
Updatedes5-ext@~0.10.10