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