2024-01-16 21:26:16 +08:00
|
|
|
var _typeof = require("./typeof.js")["default"];
|
|
|
|
function toPrimitive(t, r) {
|
|
|
|
if ("object" != _typeof(t) || !t) return t;
|
|
|
|
var e = t[Symbol.toPrimitive];
|
|
|
|
if (void 0 !== e) {
|
|
|
|
var i = e.call(t, r || "default");
|
|
|
|
if ("object" != _typeof(i)) return i;
|
2023-12-18 13:12:25 +08:00
|
|
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
|
|
}
|
2024-01-16 21:26:16 +08:00
|
|
|
return ("string" === r ? String : Number)(t);
|
2023-12-18 13:12:25 +08:00
|
|
|
}
|
2024-01-16 21:26:16 +08:00
|
|
|
module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
|