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 {
277
277
return this . db . readUIntBE ( offset , size ) ;
278
278
}
279
279
if ( size == 8 ) {
280
- return this . db . readBigInt64BE ( offset ) . toString ( ) ;
280
+ return this . db . readBigUInt64BE ( offset ) . toString ( ) ;
281
281
}
282
282
if ( size > 16 ) {
283
283
return 0 ;
@@ -290,17 +290,11 @@ export default class Decoder {
290
290
}
291
291
292
292
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 ) ) ;
302
297
}
303
-
304
298
return integer . toString ( ) ;
305
299
}
306
300
}
You can’t perform that action at this time.
0 commit comments