@@ -71,58 +71,8 @@ export class Version extends Enum {
7171 get Uint16 ( ) { return Uint16 . fromValue ( + this ) ; }
7272 get byte ( ) { return this . Uint16 }
7373
74- /**
75- * Converts this Version instance to a ProtocolVersion.
76- *
77- * @returns {ProtocolVersion } A ProtocolVersion instance representing this Version.
78- */
79- protocolVersion ( ) {
80- return ProtocolVersion . fromVersion ( this )
81- }
8274}
8375
84- /**
85- * Represents a Protocol Version as a 16-bit unsigned integer.
86- * Extends Uint16 to handle 2-byte representations of protocol versions.
87- */
88- export class ProtocolVersion extends Uint8Array {
89- /**
90- * The `Version` instance associated with this `ProtocolVersion`.
91- * @type {Version }
92- */
93- version
94- /**
95- * Creates a ProtocolVersion instance from a Version.
96- *
97- * @param {Version|number } version - A `Version` instance or a version number (as a 16-bit integer).
98- */
99- constructor ( version ) {
100- const uint16 = Uint16 . fromValue ( + version ) ;
101- super ( uint16 ) ;
102- this . version = version
103- }
104- /**
105- * Creates a new ProtocolVersion from a Version instance.
106- *
107- * @static
108- * @param {Version } version - The `Version` instance to convert to a ProtocolVersion.
109- * @returns {ProtocolVersion } A new `ProtocolVersion` instance representing the specified version.
110- */
111- static fromVersion ( version ) {
112- return new ProtocolVersion ( version )
113- }
114- /**
115- * Parses a Uint8Array and creates a ProtocolVersion.
116- *
117- * @static
118- * @param {Uint8Array } array - A 2-byte array representing a protocol version.
119- * @returns {ProtocolVersion } A new `ProtocolVersion` instance based on the parsed array.
120- * @throws {Error } If the array does not represent a valid Version.
121- */
122- static from ( array ) {
123- const version = Version . from ( array ) ;
124- return ProtocolVersion . fromVersion ( version ) ;
125- }
126- }
76+
12777
12878// npx -p typescript tsc ./src/version.js --declaration --allowJs --emitDeclarationOnly --lib ESNext --outDir ./dist
0 commit comments