massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / map-emplace.js
1 'use strict';
2 var call = require('../internals/function-call');
3 var aCallable = require('../internals/a-callable');
4 var anObject = require('../internals/an-object');
5
6 // `Map.prototype.emplace` method
7 // https://github.com/thumbsupep/proposal-upsert
8 module.exports = function emplace(key, handler) {
9   var map = anObject(this);
10   var get = aCallable(map.get);
11   var has = aCallable(map.has);
12   var set = aCallable(map.set);
13   var value = (call(has, map, key) && 'update' in handler)
14     ? handler.update(call(get, map, key), key, map)
15     : handler.insert(key, map);
16   call(set, map, key, value);
17   return value;
18 };