bireader 1.0.39 → 1.0.40
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/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +14 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +14 -4
- package/package.json +1 -1
package/lib/esm/index.mjs
CHANGED
|
@@ -80,8 +80,11 @@ function alignRev(_this, n) {
|
|
|
80
80
|
_this.skip(a * -1);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function goto(_this,
|
|
84
|
-
|
|
83
|
+
function goto(_this, bytes, bits) {
|
|
84
|
+
var new_size = (((bytes || 0)) + Math.ceil(((bits || 0)) / 8));
|
|
85
|
+
if (bits && bits < 0) {
|
|
86
|
+
new_size = Math.floor(((((bytes || 0)) * 8) + (bits || 0)) / 8);
|
|
87
|
+
}
|
|
85
88
|
if (new_size > _this.size) {
|
|
86
89
|
if (_this.strict == false) {
|
|
87
90
|
_this.extendArray(new_size - _this.size);
|
|
@@ -91,8 +94,15 @@ function goto(_this, byte, bit) {
|
|
|
91
94
|
throw new Error("\x1b[33m[Strict mode]\x1b[0m: Goto utside of range of data: goto " + new_size + " of " + _this.size);
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
|
-
_this.offset =
|
|
95
|
-
|
|
97
|
+
_this.offset = bytes;
|
|
98
|
+
// Adjust byte offset based on bit overflow
|
|
99
|
+
_this.offset += Math.floor(((bits || 0)) / 8);
|
|
100
|
+
// Adjust bit offset
|
|
101
|
+
_this.bitoffset = ((bits || 0) + 64) % 8;
|
|
102
|
+
// Ensure bit offset stays between 0-7
|
|
103
|
+
_this.bitoffset = Math.min(Math.max(_this.bitoffset, 0), 7);
|
|
104
|
+
// Ensure offset doesn't go negative
|
|
105
|
+
_this.offset = Math.max(_this.offset, 0);
|
|
96
106
|
}
|
|
97
107
|
function remove(_this, startOffset, endOffset, consume, remove, fillValue) {
|
|
98
108
|
const new_start = Math.abs(startOffset || 0);
|