82f2b76e25
We now use webpack instead of SystemJS, effectively bundling modules into one file (plus commons chunks) for every entry point. This results in a much smaller extension size (almost half). Furthermore we use yarn/npm even for extension run-time dependencies. This relieves us from manually vendoring and building dependencies. It's also easier to understand for new developers familiar with node.
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
'use strict';
|
|
var $ = require('./$')
|
|
, redefine = require('./$.redefine')
|
|
, weak = require('./$.collection-weak')
|
|
, isObject = require('./$.is-object')
|
|
, has = require('./$.has')
|
|
, frozenStore = weak.frozenStore
|
|
, WEAK = weak.WEAK
|
|
, isExtensible = Object.isExtensible || isObject
|
|
, tmp = {};
|
|
|
|
// 23.3 WeakMap Objects
|
|
var $WeakMap = require('./$.collection')('WeakMap', function(get){
|
|
return function WeakMap(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
|
|
}, {
|
|
// 23.3.3.3 WeakMap.prototype.get(key)
|
|
get: function get(key){
|
|
if(isObject(key)){
|
|
if(!isExtensible(key))return frozenStore(this).get(key);
|
|
if(has(key, WEAK))return key[WEAK][this._i];
|
|
}
|
|
},
|
|
// 23.3.3.5 WeakMap.prototype.set(key, value)
|
|
set: function set(key, value){
|
|
return weak.def(this, key, value);
|
|
}
|
|
}, weak, true, true);
|
|
|
|
// IE11 WeakMap frozen keys fix
|
|
if(new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
|
|
$.each.call(['delete', 'has', 'get', 'set'], function(key){
|
|
var proto = $WeakMap.prototype
|
|
, method = proto[key];
|
|
redefine(proto, key, function(a, b){
|
|
// store frozen objects on leaky map
|
|
if(isObject(a) && !isExtensible(a)){
|
|
var result = frozenStore(this)[key](a, b);
|
|
return key == 'set' ? this : result;
|
|
// store all the rest on native weakmap
|
|
} return method.call(this, a, b);
|
|
});
|
|
});
|
|
} |