massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / esnext.map.update.js
1 'use strict';
2 var IS_PURE = require('../internals/is-pure');
3 var $ = require('../internals/export');
4 var global = require('../internals/global');
5 var call = require('../internals/function-call');
6 var anObject = require('../internals/an-object');
7 var aCallable = require('../internals/a-callable');
8
9 var TypeError = global.TypeError;
10
11 // `Set.prototype.update` method
12 // https://github.com/tc39/proposal-collection-methods
13 $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
14   update: function update(key, callback /* , thunk */) {
15     var map = anObject(this);
16     var get = aCallable(map.get);
17     var has = aCallable(map.has);
18     var set = aCallable(map.set);
19     var length = arguments.length;
20     aCallable(callback);
21     var isPresentInMap = call(has, map, key);
22     if (!isPresentInMap && length < 3) {
23       throw TypeError('Updating absent value');
24     }
25     var value = isPresentInMap ? call(get, map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map);
26     call(set, map, key, callback(value, key, map));
27     return map;
28   }
29 });