0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2024-12-23 22:13:48 +01:00
Doodle3D-API/jspm_packages/npm/core-js@0.9.18/modules/es6.weak-map.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-07-15 15:06:18 +02:00
/* */
'use strict';
var $ = require("./$"),
weak = require("./$.collection-weak"),
leakStore = weak.leakStore,
ID = weak.ID,
WEAK = weak.WEAK,
has = $.has,
isObject = $.isObject,
isExtensible = Object.isExtensible || isObject,
tmp = {};
var $WeakMap = require("./$.collection")('WeakMap', function(get) {
return function WeakMap() {
return get(this, arguments[0]);
};
}, {
get: function get(key) {
if (isObject(key)) {
if (!isExtensible(key))
return leakStore(this).get(key);
if (has(key, WEAK))
return key[WEAK][this[ID]];
}
},
set: function set(key, value) {
return weak.def(this, key, value);
}
}, weak, true, true);
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];
require("./$.redef")(proto, key, function(a, b) {
if (isObject(a) && !isExtensible(a)) {
var result = leakStore(this)[key](a, b);
return key == 'set' ? this : result;
}
return method.call(this, a, b);
});
});
}