@@ -70,10 +70,10 @@ export class StringSchema extends Schema<string> {
7070}
7171
7272////
73- // BYTE
73+ // i8
7474////
7575
76- export class ByteSchema extends Schema < number > {
76+ export class Int8Schema extends Schema < number > {
7777 /**
7878 * The maximum number of bytes this schema can take up.
7979 *
@@ -82,11 +82,11 @@ export class ByteSchema extends Schema<number> {
8282 readonly maxSize = 1 ;
8383
8484 read ( input : ISerialInput ) : number {
85- return input . readByte ( ) ;
85+ return input . readInt8 ( ) ;
8686 }
8787
8888 write ( output : ISerialOutput , value : number ) : void {
89- output . writeByte ( value ) ;
89+ output . writeInt8 ( value ) ;
9090 }
9191
9292 measure (
@@ -97,6 +97,90 @@ export class ByteSchema extends Schema<number> {
9797 }
9898}
9999
100+ ////
101+ // u8
102+ ////
103+
104+ export class Uint8Schema extends Schema < number > {
105+ /**
106+ * The maximum number of bytes this schema can take up.
107+ *
108+ * Alias for `.measure(MaxValue).size`
109+ */
110+ readonly maxSize = 1 ;
111+
112+ read ( input : ISerialInput ) : number {
113+ return input . readUint8 ( ) ;
114+ }
115+
116+ write ( output : ISerialOutput , value : number ) : void {
117+ output . writeUint8 ( value ) ;
118+ }
119+
120+ measure (
121+ _ : number | MaxValue ,
122+ measurer : IMeasurer = new Measurer ( ) ,
123+ ) : IMeasurer {
124+ return measurer . add ( 1 ) ;
125+ }
126+ }
127+
128+ ////
129+ // i16
130+ ////
131+
132+ export class Int16Schema extends Schema < number > {
133+ /**
134+ * The maximum number of bytes this schema can take up.
135+ *
136+ * Alias for `.measure(MaxValue).size`
137+ */
138+ readonly maxSize = 2 ;
139+
140+ read ( input : ISerialInput ) : number {
141+ return input . readInt16 ( ) ;
142+ }
143+
144+ write ( output : ISerialOutput , value : number ) : void {
145+ output . writeInt16 ( value ) ;
146+ }
147+
148+ measure (
149+ _ : number | MaxValue ,
150+ measurer : IMeasurer = new Measurer ( ) ,
151+ ) : IMeasurer {
152+ return measurer . add ( 2 ) ;
153+ }
154+ }
155+
156+ ////
157+ // u16
158+ ////
159+
160+ export class Uint16Schema extends Schema < number > {
161+ /**
162+ * The maximum number of bytes this schema can take up.
163+ *
164+ * Alias for `.measure(MaxValue).size`
165+ */
166+ readonly maxSize = 2 ;
167+
168+ read ( input : ISerialInput ) : number {
169+ return input . readUint16 ( ) ;
170+ }
171+
172+ write ( output : ISerialOutput , value : number ) : void {
173+ output . writeUint16 ( value ) ;
174+ }
175+
176+ measure (
177+ _ : number | MaxValue ,
178+ measurer : IMeasurer = new Measurer ( ) ,
179+ ) : IMeasurer {
180+ return measurer . add ( 2 ) ;
181+ }
182+ }
183+
100184////
101185// i32
102186////
0 commit comments