1 | var _typeof = require("../helpers/typeof");
|
2 |
|
3 | function _toPrimitive(input, hint) {
|
4 | if (_typeof(input) !== "object" || input === null) return input;
|
5 | var prim = input[Symbol.toPrimitive];
|
6 |
|
7 | if (prim !== undefined) {
|
8 | var res = prim.call(input, hint || "default");
|
9 | if (_typeof(res) !== "object") return res;
|
10 | throw new TypeError("@@toPrimitive must return a primitive value.");
|
11 | }
|
12 |
|
13 | return (hint === "string" ? String : Number)(input);
|
14 | }
|
15 |
|
16 | module.exports = _toPrimitive; |
\ | No newline at end of file |