toPrimitive.js 682 B

12345678910111213141516171819
  1. var _Symbol$toPrimitive = require("@babel/runtime-corejs3/core-js/symbol/to-primitive");
  2. var _typeof = require("@babel/runtime-corejs3/helpers/typeof")["default"];
  3. function _toPrimitive(input, hint) {
  4. if (_typeof(input) !== "object" || input === null) return input;
  5. var prim = input[_Symbol$toPrimitive];
  6. if (prim !== undefined) {
  7. var res = prim.call(input, hint || "default");
  8. if (_typeof(res) !== "object") return res;
  9. throw new TypeError("@@toPrimitive must return a primitive value.");
  10. }
  11. return (hint === "string" ? String : Number)(input);
  12. }
  13. module.exports = _toPrimitive;
  14. module.exports["default"] = module.exports, module.exports.__esModule = true;