massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / ordinary-to-primitive.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/internals/ordinary-to-primitive.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/internals/ordinary-to-primitive.js
new file mode 100644 (file)
index 0000000..c8eed91
--- /dev/null
@@ -0,0 +1,16 @@
+var global = require('../internals/global');
+var call = require('../internals/function-call');
+var isCallable = require('../internals/is-callable');
+var isObject = require('../internals/is-object');
+
+var TypeError = global.TypeError;
+
+// `OrdinaryToPrimitive` abstract operation
+// https://tc39.es/ecma262/#sec-ordinarytoprimitive
+module.exports = function (input, pref) {
+  var fn, val;
+  if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
+  if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
+  if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
+  throw TypeError("Can't convert object to primitive value");
+};