source: frontend/node_modules/core-js/modules/es.weak-map.get-or-insert-computed.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var aCallable = require('../internals/a-callable');
4var aWeakMap = require('../internals/a-weak-map');
5var aWeakKey = require('../internals/a-weak-key');
6var WeakMapHelpers = require('../internals/weak-map-helpers');
7var IS_PURE = require('../internals/is-pure');
8
9var get = WeakMapHelpers.get;
10var has = WeakMapHelpers.has;
11var set = WeakMapHelpers.set;
12
13var FORCED = IS_PURE || !function () {
14 try {
15 // eslint-disable-next-line es/no-weak-map, no-throw-literal -- testing
16 if (WeakMap.prototype.getOrInsertComputed) new WeakMap().getOrInsertComputed(1, function () { throw 1; });
17 } catch (error) {
18 // FF144 Nightly - Beta 3 bug
19 // https://bugzilla.mozilla.org/show_bug.cgi?id=1988369
20 return error instanceof TypeError;
21 }
22}();
23
24// `WeakMap.prototype.getOrInsertComputed` method
25// https://tc39.es/ecma262/#sec-weakmap.prototype.getorinsertcomputed
26$({ target: 'WeakMap', proto: true, real: true, forced: FORCED }, {
27 getOrInsertComputed: function getOrInsertComputed(key, callbackfn) {
28 if (!IS_PURE) aWeakMap(this);
29 aWeakKey(key);
30 aCallable(callbackfn);
31 if (has(this, key)) return get(this, key);
32 var value = callbackfn(key);
33 set(this, key, value);
34 return value;
35 }
36});
Note: See TracBrowser for help on using the repository browser.