bireader 3.1.10 → 3.1.11

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/dist/index.cjs.js CHANGED
@@ -1001,7 +1001,7 @@ function wbit$1(ctx, value, bits, unsigned, endian) {
1001
1001
  if (bits <= 0 || bits > 32) {
1002
1002
  throw new Error('Bit length must be between 1 and 32. Got ' + bits);
1003
1003
  }
1004
- if (unsigned == true) {
1004
+ if (unsigned == true || bits == 1) {
1005
1005
  if (value < 0 || value > Math.pow(2, bits)) {
1006
1006
  ctx.errorDump ? "[Error], hexdump:\n" + ctx.hexdump() : "";
1007
1007
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + 0 + " max: " + Math.pow(2, bits) + " value: " + value);
@@ -1015,7 +1015,7 @@ function wbit$1(ctx, value, bits, unsigned, endian) {
1015
1015
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + minValue + " max: " + maxValue + " value: " + value);
1016
1016
  }
1017
1017
  }
1018
- if (unsigned == true) {
1018
+ if (unsigned == true || bits == 1) {
1019
1019
  const maxValue = Math.pow(2, bits) - 1;
1020
1020
  value = value & maxValue;
1021
1021
  }
@@ -10799,7 +10799,7 @@ function wbit(ctx, value, bits, unsigned, endian) {
10799
10799
  if (bits <= 0 || bits > 32) {
10800
10800
  throw new Error('Bit length must be between 1 and 32. Got ' + bits);
10801
10801
  }
10802
- if (unsigned == true) {
10802
+ if (unsigned == true || bits == 1) {
10803
10803
  if (value < 0 || value > Math.pow(2, bits)) {
10804
10804
  ctx.errorDump ? "[Error], hexdump:\n" + ctx.hexdump() : "";
10805
10805
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + 0 + " max: " + Math.pow(2, bits) + " value: " + value);
@@ -10813,7 +10813,7 @@ function wbit(ctx, value, bits, unsigned, endian) {
10813
10813
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + minValue + " max: " + maxValue + " value: " + value);
10814
10814
  }
10815
10815
  }
10816
- if (unsigned == true) {
10816
+ if (unsigned == true || bits == 1) {
10817
10817
  const maxValue = Math.pow(2, bits) - 1;
10818
10818
  value = value & maxValue;
10819
10819
  }