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.esm.js CHANGED
@@ -980,7 +980,7 @@ function wbit$1(ctx, value, bits, unsigned, endian) {
980
980
  if (bits <= 0 || bits > 32) {
981
981
  throw new Error('Bit length must be between 1 and 32. Got ' + bits);
982
982
  }
983
- if (unsigned == true) {
983
+ if (unsigned == true || bits == 1) {
984
984
  if (value < 0 || value > Math.pow(2, bits)) {
985
985
  ctx.errorDump ? "[Error], hexdump:\n" + ctx.hexdump() : "";
986
986
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + 0 + " max: " + Math.pow(2, bits) + " value: " + value);
@@ -994,7 +994,7 @@ function wbit$1(ctx, value, bits, unsigned, endian) {
994
994
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + minValue + " max: " + maxValue + " value: " + value);
995
995
  }
996
996
  }
997
- if (unsigned == true) {
997
+ if (unsigned == true || bits == 1) {
998
998
  const maxValue = Math.pow(2, bits) - 1;
999
999
  value = value & maxValue;
1000
1000
  }
@@ -10778,7 +10778,7 @@ function wbit(ctx, value, bits, unsigned, endian) {
10778
10778
  if (bits <= 0 || bits > 32) {
10779
10779
  throw new Error('Bit length must be between 1 and 32. Got ' + bits);
10780
10780
  }
10781
- if (unsigned == true) {
10781
+ if (unsigned == true || bits == 1) {
10782
10782
  if (value < 0 || value > Math.pow(2, bits)) {
10783
10783
  ctx.errorDump ? "[Error], hexdump:\n" + ctx.hexdump() : "";
10784
10784
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + 0 + " max: " + Math.pow(2, bits) + " value: " + value);
@@ -10792,7 +10792,7 @@ function wbit(ctx, value, bits, unsigned, endian) {
10792
10792
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + minValue + " max: " + maxValue + " value: " + value);
10793
10793
  }
10794
10794
  }
10795
- if (unsigned == true) {
10795
+ if (unsigned == true || bits == 1) {
10796
10796
  const maxValue = Math.pow(2, bits) - 1;
10797
10797
  value = value & maxValue;
10798
10798
  }