1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = defineToStringTag;
|
7 |
|
8 | /**
|
9 | * The `defineToStringTag()` function checks first to see if the runtime
|
10 | * supports the `Symbol` class and then if the `Symbol.toStringTag` constant
|
11 | * is defined as a `Symbol` instance. If both conditions are met, the
|
12 | * Symbol.toStringTag property is defined as a getter that returns the
|
13 | * supplied class constructor's name.
|
14 | *
|
15 | * @method defineToStringTag
|
16 | *
|
17 | * @param {Class<any>} classObject a class such as Object, String, Number but
|
18 | * typically one of your own creation through the class keyword; `class A {}`,
|
19 | * for example.
|
20 | */
|
21 | function defineToStringTag(classObject) {
|
22 | if (typeof Symbol === 'function' && Symbol.toStringTag) {
|
23 | Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
|
24 | get: function get() {
|
25 | return this.constructor.name;
|
26 | }
|
27 | });
|
28 | }
|
29 | }
|