Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
473 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | import _typeof from "@babel/runtime/helpers/typeof";
|
---|
| 2 | export default function _toPrimitive(input, hint) {
|
---|
| 3 | if (_typeof(input) !== "object" || input === null) return input;
|
---|
| 4 | var prim = input[Symbol.toPrimitive];
|
---|
| 5 |
|
---|
| 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 |
|
---|
| 12 | return (hint === "string" ? String : Number)(input);
|
---|
| 13 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.