source: imaps-frontend/node_modules/core-js/modules/esnext.weak-map.emplace.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 799 bytes
Line 
1'use strict';
2var $ = require('../internals/export');
3var aWeakMap = require('../internals/a-weak-map');
4var WeakMapHelpers = require('../internals/weak-map-helpers');
5
6var get = WeakMapHelpers.get;
7var has = WeakMapHelpers.has;
8var set = WeakMapHelpers.set;
9
10// `WeakMap.prototype.emplace` method
11// https://github.com/tc39/proposal-upsert
12$({ target: 'WeakMap', proto: true, real: true, forced: true }, {
13 emplace: function emplace(key, handler) {
14 var map = aWeakMap(this);
15 var value, inserted;
16 if (has(map, key)) {
17 value = get(map, key);
18 if ('update' in handler) {
19 value = handler.update(value, key, map);
20 set(map, key, value);
21 } return value;
22 }
23 inserted = handler.insert(key, map);
24 set(map, key, inserted);
25 return inserted;
26 }
27});
Note: See TracBrowser for help on using the repository browser.