File tree Expand file tree Collapse file tree 1 file changed +9
-17
lines changed
Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -4,34 +4,26 @@ const String = globalThis["String"];
44const Number = globalThis [ "Number" ] ;
55const Boolean = globalThis [ "Boolean" ] ;
66
7- class Type extends String {
7+ class Type {
88 /**
99 * @constructor
10- * @param {string } typeName - The type's name, regardless of whether it's an object or a primitive .
11- * @param {string } [objectType] - If this is an object , the object's name. Falsy for a primitive .
10+ * @param {string } typeName - The result of the `typeof` operator .
11+ * @param {string } [objectType] - For objects , the object's class name. Falsy for primitives .
1212 */
1313 constructor ( typeName , objectType ) {
1414 if ( ! ( typeof typeName === "string" || typeName instanceof String ) )
1515 throw new TypeError ( "'typeName' must be a string" ) ;
1616 if ( typeName == "" )
1717 throw new RangeError ( "'typeName' cannot be an empty string" ) ;
18- typeName = String ( typeName ) ;
19- if ( objectType ) {
20- if ( ! ( typeof objectType === "string" || objectType instanceof String ) )
21- throw new TypeError ( "'objectType' must be a string" ) ;
22- objectType = String ( objectType ) ;
23- }
18+ if ( objectType && ! ( typeof objectType === "string" || objectType instanceof String ) )
19+ throw new TypeError ( "'objectType' must be a string" ) ;
2420
25- super ( ) ;
21+ this . type = typeName ;
22+ this . objectType = objectType || "" ;
2623
2724 this . type = typeName ;
28- if ( objectType ) {
29- this . objectType = objectType ;
30- this . object = true ;
31- }
32- else {
33- this . primitive = true ;
34- }
25+ this . primitive = ! this . objectType ;
26+ this . object = ! this . primitive ;
3527 }
3628}
3729
You can’t perform that action at this time.
0 commit comments