@@ -55,7 +55,7 @@ export class AvroDecoder implements BinaryJsonDecoder {
5555 public readLong ( ) : number | bigint {
5656 const zigzag = this . readVarLong ( ) ;
5757 const decoded = this . decodeZigZag64 ( zigzag ) ;
58-
58+
5959 // Return number if it fits in safe integer range, otherwise bigint
6060 if ( decoded >= BigInt ( Number . MIN_SAFE_INTEGER ) && decoded <= BigInt ( Number . MAX_SAFE_INTEGER ) ) {
6161 return Number ( decoded ) ;
@@ -106,16 +106,16 @@ export class AvroDecoder implements BinaryJsonDecoder {
106106 */
107107 public readArray < T > ( itemReader : ( ) => T ) : T [ ] {
108108 const result : T [ ] = [ ] ;
109-
109+
110110 while ( true ) {
111111 const count = this . readVarIntUnsigned ( ) ;
112112 if ( count === 0 ) break ; // End of array marker
113-
113+
114114 for ( let i = 0 ; i < count ; i ++ ) {
115115 result . push ( itemReader ( ) ) ;
116116 }
117117 }
118-
118+
119119 return result ;
120120 }
121121
@@ -125,18 +125,18 @@ export class AvroDecoder implements BinaryJsonDecoder {
125125 */
126126 public readMap < T > ( valueReader : ( ) => T ) : Record < string , T > {
127127 const result : Record < string , T > = { } ;
128-
128+
129129 while ( true ) {
130130 const count = this . readVarIntUnsigned ( ) ;
131131 if ( count === 0 ) break ; // End of map marker
132-
132+
133133 for ( let i = 0 ; i < count ; i ++ ) {
134134 const key = this . readString ( ) ;
135135 if ( key === '__proto__' ) throw new Error ( 'INVALID_KEY' ) ;
136136 result [ key ] = valueReader ( ) ;
137137 }
138138 }
139-
139+
140140 return result ;
141141 }
142142
@@ -149,7 +149,7 @@ export class AvroDecoder implements BinaryJsonDecoder {
149149 if ( index < 0 || index >= schemaReaders . length ) {
150150 throw new Error ( `Invalid union index: ${ index } ` ) ;
151151 }
152-
152+
153153 const value = schemaReaders [ index ] ( ) ;
154154 return { index, value} ;
155155 }
@@ -193,19 +193,19 @@ export class AvroDecoder implements BinaryJsonDecoder {
193193 const reader = this . reader ;
194194 let result = 0 ;
195195 let shift = 0 ;
196-
196+
197197 while ( true ) {
198198 const byte = reader . u8 ( ) ;
199199 result |= ( byte & 0x7f ) << shift ;
200-
200+
201201 if ( ( byte & 0x80 ) === 0 ) break ;
202-
202+
203203 shift += 7 ;
204204 if ( shift >= 32 ) {
205205 throw new Error ( 'Variable-length integer is too long' ) ;
206206 }
207207 }
208-
208+
209209 return result >>> 0 ; // Convert to unsigned 32-bit
210210 }
211211
@@ -216,19 +216,19 @@ export class AvroDecoder implements BinaryJsonDecoder {
216216 const reader = this . reader ;
217217 let result = BigInt ( 0 ) ;
218218 let shift = BigInt ( 0 ) ;
219-
219+
220220 while ( true ) {
221221 const byte = BigInt ( reader . u8 ( ) ) ;
222222 result |= ( byte & BigInt ( 0x7f ) ) << shift ;
223-
223+
224224 if ( ( byte & BigInt ( 0x80 ) ) === BigInt ( 0 ) ) break ;
225-
225+
226226 shift += BigInt ( 7 ) ;
227227 if ( shift >= BigInt ( 64 ) ) {
228228 throw new Error ( 'Variable-length long is too long' ) ;
229229 }
230230 }
231-
231+
232232 return result ;
233233 }
234234
@@ -245,4 +245,4 @@ export class AvroDecoder implements BinaryJsonDecoder {
245245 private decodeZigZag64 ( value : bigint ) : bigint {
246246 return ( value >> BigInt ( 1 ) ) ^ - ( value & BigInt ( 1 ) ) ;
247247 }
248- }
248+ }
0 commit comments