Skip to content

Commit

Permalink
add back es6-symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
qwales1 committed Oct 26, 2016
1 parent 420e230 commit b424587
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 0 deletions.
186 changes: 186 additions & 0 deletions dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ return /******/ (function(modules) { // webpackBootstrap
var firebase = __webpack_require__(2);
var Map = __webpack_require__(3);
var WeakMap = __webpack_require__(61);
var Symbol = __webpack_require__(72);
var firebaseApp = null;
var rebase;
var firebaseRefs = new Map();
Expand Down Expand Up @@ -2754,6 +2755,191 @@ return /******/ (function(modules) { // webpackBootstrap
}());


/***/ },
/* 72 */
/***/ function(module, exports, __webpack_require__) {

'use strict';

module.exports = __webpack_require__(73)() ? Symbol : __webpack_require__(74);


/***/ },
/* 73 */
/***/ function(module, exports) {

'use strict';

var validTypes = { object: true, symbol: true };

module.exports = function () {
var symbol;
if (typeof Symbol !== 'function') return false;
symbol = Symbol('test symbol');
try { String(symbol); } catch (e) { return false; }

// Return 'true' also for polyfills
if (!validTypes[typeof Symbol.iterator]) return false;
if (!validTypes[typeof Symbol.toPrimitive]) return false;
if (!validTypes[typeof Symbol.toStringTag]) return false;

return true;
};


/***/ },
/* 74 */
/***/ function(module, exports, __webpack_require__) {

// ES2015 Symbol polyfill for environments that do not support it (or partially support it)

'use strict';

var d = __webpack_require__(20)
, validateSymbol = __webpack_require__(75)

, create = Object.create, defineProperties = Object.defineProperties
, defineProperty = Object.defineProperty, objPrototype = Object.prototype
, NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create(null)
, isNativeSafe;

if (typeof Symbol === 'function') {
NativeSymbol = Symbol;
try {
String(NativeSymbol());
isNativeSafe = true;
} catch (ignore) {}
}

var generateName = (function () {
var created = create(null);
return function (desc) {
var postfix = 0, name, ie11BugWorkaround;
while (created[desc + (postfix || '')]) ++postfix;
desc += (postfix || '');
created[desc] = true;
name = '@@' + desc;
defineProperty(objPrototype, name, d.gs(null, function (value) {
// For IE11 issue see:
// https://connect.microsoft.com/IE/feedbackdetail/view/1928508/
// ie11-broken-getters-on-dom-objects
// https://github.com/medikoo/es6-symbol/issues/12
if (ie11BugWorkaround) return;
ie11BugWorkaround = true;
defineProperty(this, name, d(value));
ie11BugWorkaround = false;
}));
return name;
};
}());

// 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) {
if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor');
return SymbolPolyfill(description);
};

// Exposed `Symbol` constructor
// (returns instances of HiddenSymbol)
module.exports = SymbolPolyfill = function Symbol(description) {
var symbol;
if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor');
if (isNativeSafe) return NativeSymbol(description);
symbol = create(HiddenSymbol.prototype);
description = (description === undefined ? '' : String(description));
return defineProperties(symbol, {
__description__: d('', description),
__name__: d('', generateName(description))
});
};
defineProperties(SymbolPolyfill, {
for: d(function (key) {
if (globalSymbols[key]) return globalSymbols[key];
return (globalSymbols[key] = SymbolPolyfill(String(key)));
}),
keyFor: d(function (s) {
var key;
validateSymbol(s);
for (key in globalSymbols) if (globalSymbols[key] === s) return key;
}),

// 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')),
isConcatSpreadable: d('', (NativeSymbol && NativeSymbol.isConcatSpreadable) ||
SymbolPolyfill('isConcatSpreadable')),
iterator: d('', (NativeSymbol && NativeSymbol.iterator) || SymbolPolyfill('iterator')),
match: d('', (NativeSymbol && NativeSymbol.match) || SymbolPolyfill('match')),
replace: d('', (NativeSymbol && NativeSymbol.replace) || SymbolPolyfill('replace')),
search: d('', (NativeSymbol && NativeSymbol.search) || SymbolPolyfill('search')),
species: d('', (NativeSymbol && NativeSymbol.species) || SymbolPolyfill('species')),
split: d('', (NativeSymbol && NativeSymbol.split) || SymbolPolyfill('split')),
toPrimitive: d('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')),
toStringTag: d('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')),
unscopables: d('', (NativeSymbol && NativeSymbol.unscopables) || SymbolPolyfill('unscopables'))
});

// Internal tweaks for real symbol producer
defineProperties(HiddenSymbol.prototype, {
constructor: d(SymbolPolyfill),
toString: d('', function () { return this.__name__; })
});

// 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, {
toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }),
valueOf: d(function () { return validateSymbol(this); })
});
defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('', function () {
var symbol = validateSymbol(this);
if (typeof symbol === 'symbol') return symbol;
return symbol.toString();
}));
defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d('c', 'Symbol'));

// 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]));


/***/ },
/* 75 */
/***/ function(module, exports, __webpack_require__) {

'use strict';

var isSymbol = __webpack_require__(76);

module.exports = function (value) {
if (!isSymbol(value)) throw new TypeError(value + " is not a symbol");
return value;
};


/***/ },
/* 76 */
/***/ function(module, exports) {

'use strict';

module.exports = function (x) {
if (!x) return false;
if (typeof x === 'symbol') return true;
if (!x.constructor) return false;
if (x.constructor.name !== 'Symbol') return false;
return (x[x.constructor.toStringTag] === 'Symbol');
};


/***/ }
/******/ ])
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"author": "Tyler McGinnis and Jacob Turner",
"dependencies": {
"es6-map": "^0.1.4",
"es6-symbol": "^3.1.0",
"es6-weak-map": "^2.0.1",
"firebase": "^3.3.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/rebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = (function(){
var firebase = require('firebase');
var Map = require('es6-map');
var WeakMap = require('es6-weak-map');
var Symbol = require('es6-symbol');
var firebaseApp = null;
var rebase;
var firebaseRefs = new Map();
Expand Down

0 comments on commit b424587

Please sign in to comment.