File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ export default class Decoder {
277277 return this . db . readUIntBE ( offset , size ) ;
278278 }
279279 if ( size == 8 ) {
280- return this . db . readBigInt64BE ( offset ) . toString ( ) ;
280+ return this . db . readBigUInt64BE ( offset ) . toString ( ) ;
281281 }
282282 if ( size > 16 ) {
283283 return 0 ;
@@ -290,17 +290,11 @@ export default class Decoder {
290290 }
291291
292292 private decodeBigUint ( offset : number , size : number ) {
293- const buffer = Buffer . alloc ( size ) ;
294- this . db . copy ( buffer , 0 , offset , offset + size ) ;
295-
296- let integer = BigInt ( 0 ) ;
297-
298- const numberOfLongs = size / 4 ;
299- for ( let i = 0 ; i < numberOfLongs ; i ++ ) {
300- integer =
301- integer * BigInt ( 4294967296 ) + BigInt ( buffer . readUInt32BE ( i << 2 ) ) ;
293+ let integer = 0n ;
294+ for ( let i = 0 ; i < size ; i ++ ) {
295+ integer <<= 8n ;
296+ integer |= BigInt ( this . db . readUInt8 ( offset + i ) ) ;
302297 }
303-
304298 return integer . toString ( ) ;
305299 }
306300}
You can’t perform that action at this time.
0 commit comments