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/README.md CHANGED
@@ -746,7 +746,9 @@ Common functions for setup, movement, manipulation and math shared by both.
746
746
 
747
747
  ## BiStreams
748
748
 
749
- With 3.1 you can now use ``BiReaderStream`` and ``BiWriterStream`` (Node only) designed for larger files (or if you don't want or need the whole file loaded to memory all at once).
749
+ With 3.1 you can now use ``BiReaderStream`` and ``BiWriterStream`` (Node.js only) designed for larger files (or if you don't want to or need to load the whole file loaded to memory all at once).
750
+
751
+ **Programmers Note:** These are *NOT* data streams like ``fs.createReadStream`` where the whole file is streamed over time. It uses ``fs.openSync`` and ``fs.readSync`` and ``fs.writeSync`` to read and write just the data requested at the position requested at the time of operation, saving memory but costing processing power. This is mostly for legacy uses and niche cases as the newer versions of the Node.js have a much larger Buffer size over the older 4gig limit.
750
752
 
751
753
  <table>
752
754
  <thead>
@@ -977,7 +977,7 @@ function wbit(ctx, value, bits, unsigned, endian) {
977
977
  if (bits <= 0 || bits > 32) {
978
978
  throw new Error('Bit length must be between 1 and 32. Got ' + bits);
979
979
  }
980
- if (unsigned == true) {
980
+ if (unsigned == true || bits == 1) {
981
981
  if (value < 0 || value > Math.pow(2, bits)) {
982
982
  ctx.errorDump ? "[Error], hexdump:\n" + ctx.hexdump() : "";
983
983
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + 0 + " max: " + Math.pow(2, bits) + " value: " + value);
@@ -991,7 +991,7 @@ function wbit(ctx, value, bits, unsigned, endian) {
991
991
  throw new Error(`Value is out of range for the specified ${bits}bit length.` + " min: " + minValue + " max: " + maxValue + " value: " + value);
992
992
  }
993
993
  }
994
- if (unsigned == true) {
994
+ if (unsigned == true || bits == 1) {
995
995
  const maxValue = Math.pow(2, bits) - 1;
996
996
  value = value & maxValue;
997
997
  }