toPrimitive.js 494 B

123456789101112
  1. var _typeof = require("./typeof.js")["default"];
  2. function toPrimitive(t, r) {
  3. if ("object" != _typeof(t) || !t) return t;
  4. var e = t[Symbol.toPrimitive];
  5. if (void 0 !== e) {
  6. var i = e.call(t, r || "default");
  7. if ("object" != _typeof(i)) return i;
  8. throw new TypeError("@@toPrimitive must return a primitive value.");
  9. }
  10. return ("string" === r ? String : Number)(t);
  11. }
  12. module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;