bireader 1.0.33 → 1.0.35
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 +21 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +37 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.d.ts +21 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +37 -4
- package/package.json +1 -1
package/lib/esm/index.mjs
CHANGED
|
@@ -44,8 +44,10 @@ export function checkSize(_this, write_bytes, write_bit, offset) {
|
|
|
44
44
|
return new_off;
|
|
45
45
|
}
|
|
46
46
|
export function skip(_this, bytes, bits) {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
var new_size = (((bytes || 0) + _this.offset) + Math.ceil((_this.bitoffset + (bits || 0)) / 8));
|
|
48
|
+
if (bits && bits < 0) {
|
|
49
|
+
new_size = Math.floor(((((bytes || 0) + _this.offset) * 8) + _this.bitoffset + (bits || 0)) / 8);
|
|
50
|
+
}
|
|
49
51
|
if (new_size > _this.size) {
|
|
50
52
|
if (_this.strict == false) {
|
|
51
53
|
_this.extendArray(new_size - _this.size);
|
|
@@ -55,8 +57,14 @@ export function skip(_this, bytes, bits) {
|
|
|
55
57
|
throw new Error("\x1b[33m[Strict mode]\x1b[0m: Seek of range of data: seek " + new_size + " of " + _this.size);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
if (bits && bits < 0) {
|
|
61
|
+
_this.bitoffset = ((_this.bitoffset + (bits || 0) % 8) + 8) % 8;
|
|
62
|
+
_this.offset = new_size;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
_this.bitoffset += (bits || 0) % 8;
|
|
66
|
+
_this.offset += (bytes || 0);
|
|
67
|
+
}
|
|
60
68
|
}
|
|
61
69
|
export function goto(_this, byte, bit) {
|
|
62
70
|
const new_size = (byte + Math.ceil((bit || 0) / 8));
|
|
@@ -2304,6 +2312,18 @@ export class bireader {
|
|
|
2304
2312
|
*
|
|
2305
2313
|
* Note: When returning to a byte read, remaining bits are dropped
|
|
2306
2314
|
*
|
|
2315
|
+
* @param {number} bits - bits to read
|
|
2316
|
+
* @param {string} endian - ``big`` or ``little`
|
|
2317
|
+
* @returns number
|
|
2318
|
+
*/
|
|
2319
|
+
ubit(bits, endian) {
|
|
2320
|
+
return this.readBit(bits, true, endian);
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Bit field reader
|
|
2324
|
+
*
|
|
2325
|
+
* Note: When returning to a byte read, remaining bits are dropped
|
|
2326
|
+
*
|
|
2307
2327
|
* @param {boolean} unsigned - if the value is unsigned
|
|
2308
2328
|
* @param {string} endian - ``big`` or ``little`
|
|
2309
2329
|
* @returns number
|
|
@@ -6711,6 +6731,19 @@ export class biwriter {
|
|
|
6711
6731
|
*
|
|
6712
6732
|
* @param {number} value - value as int
|
|
6713
6733
|
* @param {number} bits - bits to write
|
|
6734
|
+
* @param {string} endian - ``big`` or ``little`
|
|
6735
|
+
* @returns number
|
|
6736
|
+
*/
|
|
6737
|
+
ubit(value, bits, endian) {
|
|
6738
|
+
return this.writeBit(value, bits, true, endian);
|
|
6739
|
+
}
|
|
6740
|
+
/**
|
|
6741
|
+
* Bit field writer
|
|
6742
|
+
*
|
|
6743
|
+
* Note: When returning to a byte write, remaining bits are dropped
|
|
6744
|
+
*
|
|
6745
|
+
* @param {number} value - value as int
|
|
6746
|
+
* @param {number} bits - bits to write
|
|
6714
6747
|
* @returns number
|
|
6715
6748
|
*/
|
|
6716
6749
|
writeUBitBE(value, bits) {
|