source: trip-planner-front/node_modules/core-js/modules/es.weak-map.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.8 KB
Line 
1'use strict';
2var global = require('../internals/global');
3var redefineAll = require('../internals/redefine-all');
4var InternalMetadataModule = require('../internals/internal-metadata');
5var collection = require('../internals/collection');
6var collectionWeak = require('../internals/collection-weak');
7var isObject = require('../internals/is-object');
8var enforceIternalState = require('../internals/internal-state').enforce;
9var NATIVE_WEAK_MAP = require('../internals/native-weak-map');
10
11var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
12// eslint-disable-next-line es/no-object-isextensible -- safe
13var isExtensible = Object.isExtensible;
14var InternalWeakMap;
15
16var wrapper = function (init) {
17 return function WeakMap() {
18 return init(this, arguments.length ? arguments[0] : undefined);
19 };
20};
21
22// `WeakMap` constructor
23// https://tc39.es/ecma262/#sec-weakmap-constructor
24var $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak);
25
26// IE11 WeakMap frozen keys fix
27// We can't use feature detection because it crash some old IE builds
28// https://github.com/zloirock/core-js/issues/485
29if (NATIVE_WEAK_MAP && IS_IE11) {
30 InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
31 InternalMetadataModule.enable();
32 var WeakMapPrototype = $WeakMap.prototype;
33 var nativeDelete = WeakMapPrototype['delete'];
34 var nativeHas = WeakMapPrototype.has;
35 var nativeGet = WeakMapPrototype.get;
36 var nativeSet = WeakMapPrototype.set;
37 redefineAll(WeakMapPrototype, {
38 'delete': function (key) {
39 if (isObject(key) && !isExtensible(key)) {
40 var state = enforceIternalState(this);
41 if (!state.frozen) state.frozen = new InternalWeakMap();
42 return nativeDelete.call(this, key) || state.frozen['delete'](key);
43 } return nativeDelete.call(this, key);
44 },
45 has: function has(key) {
46 if (isObject(key) && !isExtensible(key)) {
47 var state = enforceIternalState(this);
48 if (!state.frozen) state.frozen = new InternalWeakMap();
49 return nativeHas.call(this, key) || state.frozen.has(key);
50 } return nativeHas.call(this, key);
51 },
52 get: function get(key) {
53 if (isObject(key) && !isExtensible(key)) {
54 var state = enforceIternalState(this);
55 if (!state.frozen) state.frozen = new InternalWeakMap();
56 return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);
57 } return nativeGet.call(this, key);
58 },
59 set: function set(key, value) {
60 if (isObject(key) && !isExtensible(key)) {
61 var state = enforceIternalState(this);
62 if (!state.frozen) state.frozen = new InternalWeakMap();
63 nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);
64 } else nativeSet.call(this, key, value);
65 return this;
66 }
67 });
68}
Note: See TracBrowser for help on using the repository browser.