bireader 1.0.34 → 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/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
- const new_size = (((bytes || 0) + _this.offset) + Math.ceil((_this.bitoffset + (bits || 0)) / 8));
48
- check_size(_this, bytes || 0, bits || 0);
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
- _this.bitoffset += (bits || 0) % 8;
59
- _this.offset += (bytes || 0);
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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bireader",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "Read and write data in binary",
5
5
  "module": "lib/esm/index.mjs",
6
6
  "main": "lib/cjs/index.js",