bireader 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/reader.js +7 -11
package/package.json
CHANGED
package/src/reader.js
CHANGED
|
@@ -21,10 +21,6 @@ class bireader {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
#flip = function(unsignedValue){
|
|
25
|
-
return unsignedValue > 127 ? unsignedValue - 256 : unsignedValue;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
/**
|
|
29
25
|
*
|
|
30
26
|
* byte reader, includes bitfields and strings
|
|
@@ -2489,12 +2485,12 @@ class bireader {
|
|
|
2489
2485
|
*/
|
|
2490
2486
|
readByte = this.byte = this.int8 = function(unsigned){
|
|
2491
2487
|
this.#check_size(1)
|
|
2492
|
-
|
|
2488
|
+
var read = this.data[this.offset]
|
|
2493
2489
|
this.offset += 1
|
|
2494
2490
|
if(unsigned == true){
|
|
2495
2491
|
return read & 0xFF
|
|
2496
2492
|
} else {
|
|
2497
|
-
return read
|
|
2493
|
+
return read > 127 ? read - 256 : read;
|
|
2498
2494
|
}
|
|
2499
2495
|
}
|
|
2500
2496
|
|
|
@@ -2522,13 +2518,13 @@ class bireader {
|
|
|
2522
2518
|
this.#check_size(2)
|
|
2523
2519
|
var read
|
|
2524
2520
|
if((endian != undefined ? endian : this.endian) == "little"){
|
|
2525
|
-
read = (
|
|
2521
|
+
read = ((this.data[this.offset + 1] & 0xFFFF) << 8) | (this.data[this.offset]& 0xFFFF);
|
|
2526
2522
|
} else {
|
|
2527
|
-
read = (
|
|
2523
|
+
read = ((this.data[this.offset]& 0xFFFF) << 8) | (this.data[this.offset + 1] & 0xFFFF);
|
|
2528
2524
|
}
|
|
2529
2525
|
this.offset += 2
|
|
2530
2526
|
if(unsigned == undefined || unsigned == false){
|
|
2531
|
-
return read
|
|
2527
|
+
return read & 0x8000 ? -(0x10000 - read) : read
|
|
2532
2528
|
} else {
|
|
2533
2529
|
return read & 0xFFFF
|
|
2534
2530
|
}
|
|
@@ -2793,7 +2789,7 @@ class bireader {
|
|
|
2793
2789
|
let value = BigInt(0);
|
|
2794
2790
|
if((endian == undefined ? this.endian : endian) == "little"){
|
|
2795
2791
|
for (let i = 0; i < 8; i++) {
|
|
2796
|
-
value |= BigInt(
|
|
2792
|
+
value |= BigInt((this.data[this.offset] & 0xFF)) << BigInt(8 * i);
|
|
2797
2793
|
this.offset += 1
|
|
2798
2794
|
}
|
|
2799
2795
|
if(unsigned == undefined || unsigned == false){
|
|
@@ -2806,7 +2802,7 @@ class bireader {
|
|
|
2806
2802
|
}
|
|
2807
2803
|
} else {
|
|
2808
2804
|
for (let i = 0; i < 8; i++) {
|
|
2809
|
-
value = (value << BigInt(8)) | BigInt(
|
|
2805
|
+
value = (value << BigInt(8)) | BigInt((this.data[this.offset] & 0xFF));
|
|
2810
2806
|
this.offset += 1
|
|
2811
2807
|
}
|
|
2812
2808
|
if(unsigned == undefined || unsigned == false){
|