File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 6
6
* @template Type
7
7
*/
8
8
export abstract class Value < Type > {
9
+ /**
10
+ * @description Returns the `string` tag representation of the `Value` class when used in `Object.prototype.toString.call(instance)`.
11
+ * @public
12
+ * @readonly
13
+ * @type {string }
14
+ */
15
+ public get [ Symbol . toStringTag ] ( ) {
16
+ return 'Value' ;
17
+ }
18
+
9
19
/**
10
20
* @description Returns the privately stored value of generic type variable `Type`.
11
21
* @public
@@ -32,6 +42,16 @@ export abstract class Value<Type> {
32
42
this . #value = value ;
33
43
}
34
44
45
+ /**
46
+ * @description Extracts the string tag of the current instance defined by the `Symbol.toStringTag`.
47
+ * @public
48
+ * @returns {string | undefined } The extracted class name, such as `'Value'`, or `undefined` if extraction fails.
49
+ */
50
+ public get tag ( ) : string | undefined {
51
+ const tag = Object . prototype . toString . call ( this ) . slice ( 8 , - 1 ) ;
52
+ return tag !== 'Object' ? tag : undefined ;
53
+ }
54
+
35
55
/**
36
56
* @description Sets the value of generic type variable `Type`.
37
57
* @protected
You can’t perform that action at this time.
0 commit comments