Skip to content

Commit 3a88ed3

Browse files
committed
remove ProtocolVersion
1 parent ec578b2 commit 3a88ed3

File tree

3 files changed

+4
-92
lines changed

3 files changed

+4
-92
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tls/enum",
3-
"version": "0.7.5",
3+
"version": "0.7.6",
44
"exports": "./src/mod.ts",
55
"publish": {
66
"exclude": ["dist/"]

src/version.js

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -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

type/version.d.ts

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -58,46 +58,8 @@ export class Version extends Enum {
5858
* @returns {number} The byte length, which is always 2.
5959
*/
6060
get length(): number;
61-
/**
62-
* Converts this Version instance to a ProtocolVersion.
63-
*
64-
* @returns {ProtocolVersion} A ProtocolVersion instance representing this Version.
65-
*/
66-
protocolVersion(): ProtocolVersion;
67-
}
68-
/**
69-
* Represents a Protocol Version as a 16-bit unsigned integer.
70-
* Extends Uint16 to handle 2-byte representations of protocol versions.
71-
*/
72-
export class ProtocolVersion extends Uint16 {
73-
/**
74-
* Creates a ProtocolVersion instance from a Version.
75-
*
76-
* @param {Version | number} version - A `Version` instance or a version number (as a 16-bit integer).
77-
*/
78-
constructor(version: Version | number);
79-
/**
80-
* The `Version` instance associated with this `ProtocolVersion`.
81-
* @type {Version}
82-
*/
83-
version: Version;
84-
/**
85-
* Creates a new ProtocolVersion from a Version instance.
86-
*
87-
* @static
88-
* @param {Version} version - The `Version` instance to convert to a ProtocolVersion.
89-
* @returns {ProtocolVersion} A new `ProtocolVersion` instance representing the specified version.
90-
*/
91-
static fromVersion(version: Version): ProtocolVersion;
92-
/**
93-
* Parses a Uint8Array and creates a ProtocolVersion.
94-
*
95-
* @static
96-
* @param {Uint8Array} array - A 2-byte array representing a protocol version.
97-
* @returns {ProtocolVersion} A new `ProtocolVersion` instance based on the parsed array.
98-
* @throws {Error} If the array does not represent a valid Version.
99-
*/
100-
static from(array: Uint8Array): ProtocolVersion;
61+
10162
}
10263

64+
10365
import { Enum } from "../type/enum.d.ts";

0 commit comments

Comments
 (0)