massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / map-upsert.js
index 2c51e78b9a93ff88617669643b8c6d8e9c08f910..46451809fe308522236fdfbf29b12b0ea6f87c61 100644 (file)
@@ -1,23 +1,32 @@
 'use strict';
+var global = require('../internals/global');
+var call = require('../internals/function-call');
+var aCallable = require('../internals/a-callable');
+var isCallable = require('../internals/is-callable');
 var anObject = require('../internals/an-object');
 
+var TypeError = global.TypeError;
+
 // `Map.prototype.upsert` method
 // https://github.com/thumbsupep/proposal-upsert
 module.exports = function upsert(key, updateFn /* , insertFn */) {
   var map = anObject(this);
+  var get = aCallable(map.get);
+  var has = aCallable(map.has);
+  var set = aCallable(map.set);
   var insertFn = arguments.length > 2 ? arguments[2] : undefined;
   var value;
-  if (typeof updateFn != 'function' && typeof insertFn != 'function') {
+  if (!isCallable(updateFn) && !isCallable(insertFn)) {
     throw TypeError('At least one callback required');
   }
-  if (map.has(key)) {
-    value = map.get(key);
-    if (typeof updateFn == 'function') {
+  if (call(has, map, key)) {
+    value = call(get, map, key);
+    if (isCallable(updateFn)) {
       value = updateFn(value);
-      map.set(key, value);
+      call(set, map, key, value);
     }
-  } else if (typeof insertFn == 'function') {
+  } else if (isCallable(insertFn)) {
     value = insertFn();
-    map.set(key, value);
+    call(set, map, key, value);
   } return value;
 };