bireader 3.1.7 → 3.1.8

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.
@@ -3760,7 +3760,6 @@ interface BinaryAliasReader extends BiBase {
3760
3760
  wpstring4le(stripNull?: stringOptions["stripNull"]): string;
3761
3761
  }
3762
3762
 
3763
- declare const BiReaderBase: typeof BiBase;
3764
3763
  /**
3765
3764
  * Binary reader, includes bitfields and strings.
3766
3765
  *
@@ -3774,7 +3773,7 @@ declare const BiReaderBase: typeof BiBase;
3774
3773
  *
3775
3774
  * @since 2.0
3776
3775
  */
3777
- declare class BiReader extends BiReaderBase implements BinaryAliasReader {
3776
+ declare class BiRead extends BiBase implements BinaryAliasReader {
3778
3777
  /**
3779
3778
  * Binary reader, includes bitfields and strings.
3780
3779
  *
@@ -4094,6 +4093,20 @@ declare class BiReader extends BiReaderBase implements BinaryAliasReader {
4094
4093
  wpstring4be(stripNull?: stringOptions["stripNull"]): string;
4095
4094
  wpstring4le(stripNull?: stringOptions["stripNull"]): string;
4096
4095
  }
4096
+ /**
4097
+ * Binary reader, includes bitfields and strings.
4098
+ *
4099
+ * @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
4100
+ * @param {BiOptions?} options - Any options to set at start
4101
+ * @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
4102
+ * @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
4103
+ * @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
4104
+ * @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
4105
+ * @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
4106
+ *
4107
+ * @since 2.0
4108
+ */
4109
+ declare const BiReader: typeof BiRead;
4097
4110
 
4098
4111
  interface BinaryAliasWriter extends BiBase {
4099
4112
  /**
@@ -6418,7 +6431,6 @@ interface BinaryAliasWriter extends BiBase {
6418
6431
  wpstring4be(string: string): void;
6419
6432
  }
6420
6433
 
6421
- declare const BiWriterBase: typeof BiBase;
6422
6434
  /**
6423
6435
  * Binary writer, includes bitfields and strings.
6424
6436
  *
@@ -6432,7 +6444,7 @@ declare const BiWriterBase: typeof BiBase;
6432
6444
  *
6433
6445
  * @since 2.0
6434
6446
  */
6435
- declare class BiWriter extends BiWriterBase implements BinaryAliasWriter {
6447
+ declare class BiWrite extends BiBase implements BinaryAliasWriter {
6436
6448
  /**
6437
6449
  * Binary writer, includes bitfields and strings.
6438
6450
  *
@@ -6757,6 +6769,20 @@ declare class BiWriter extends BiWriterBase implements BinaryAliasWriter {
6757
6769
  wpstring4le(string: string): void;
6758
6770
  wpstring4be(string: string): void;
6759
6771
  }
6772
+ /**
6773
+ * Binary writer, includes bitfields and strings.
6774
+ *
6775
+ * @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
6776
+ * @param {BiOptions?} options - Any options to set at start
6777
+ * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
6778
+ * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
6779
+ * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
6780
+ * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
6781
+ * @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
6782
+ *
6783
+ * @since 2.0
6784
+ */
6785
+ declare const BiWriter: typeof BiWrite;
6760
6786
 
6761
6787
  /**
6762
6788
  * Isn't usable in browser.
@@ -63,7 +63,7 @@ function _hexDump(data, options = {}, start, end) {
63
63
  var addr = "";
64
64
  for (let i = start; i < end; i += 16) {
65
65
  addr = i.toString(16).padStart(5, '0');
66
- var row = data.slice(i, i + 16) || [];
66
+ var row = data.subarray(i, i + 16) || [];
67
67
  var hex = Array.from(row, (byte) => byte.toString(16).padStart(2, '0')).join(' ');
68
68
  rows.push(`${addr} ${hex.padEnd(47)} `);
69
69
  }
@@ -367,7 +367,7 @@ function remove(ctx, startOffset, endOffset, consume, remove, fillValue) {
367
367
  ctx.errorDump ? console.log("[Error], hexdump:\n" + ctx.hexdump({ returnString: true })) : "";
368
368
  throw new Error("\x1b[33m[Strict mode]\x1b[0m: Can not remove data in strict mode: endOffset " + endOffset + " of " + ctx.size);
369
369
  }
370
- const data_removed = ctx.data.slice(new_start, new_offset);
370
+ const data_removed = ctx.data.subarray(new_start, new_offset);
371
371
  if (remove) {
372
372
  const part1 = ctx.data.subarray(0, new_start);
373
373
  const part2 = ctx.data.subarray(new_offset, ctx.size);
@@ -6589,7 +6589,6 @@ function applyBinaryAliasReader(Base) {
6589
6589
  };
6590
6590
  }
6591
6591
 
6592
- const BiReaderBase = applyBinaryAliasReader(BiBase);
6593
6592
  /**
6594
6593
  * Binary reader, includes bitfields and strings.
6595
6594
  *
@@ -6603,7 +6602,7 @@ const BiReaderBase = applyBinaryAliasReader(BiBase);
6603
6602
  *
6604
6603
  * @since 2.0
6605
6604
  */
6606
- class BiReader extends BiReaderBase {
6605
+ class BiRead extends BiBase {
6607
6606
  /**
6608
6607
  * Binary reader, includes bitfields and strings.
6609
6608
  *
@@ -7591,6 +7590,20 @@ class BiReader extends BiReaderBase {
7591
7590
  throw new Error("Method not implemented.");
7592
7591
  }
7593
7592
  }
7593
+ /**
7594
+ * Binary reader, includes bitfields and strings.
7595
+ *
7596
+ * @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
7597
+ * @param {BiOptions?} options - Any options to set at start
7598
+ * @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
7599
+ * @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
7600
+ * @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
7601
+ * @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
7602
+ * @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
7603
+ *
7604
+ * @since 2.0
7605
+ */
7606
+ const BiReader = applyBinaryAliasReader(BiRead);
7594
7607
 
7595
7608
  function applyBinaryAliasWriter(Base) {
7596
7609
  return class extends Base {
@@ -10569,7 +10582,6 @@ function applyBinaryAliasWriter(Base) {
10569
10582
  };
10570
10583
  }
10571
10584
 
10572
- const BiWriterBase = applyBinaryAliasWriter(BiBase);
10573
10585
  /**
10574
10586
  * Binary writer, includes bitfields and strings.
10575
10587
  *
@@ -10583,7 +10595,7 @@ const BiWriterBase = applyBinaryAliasWriter(BiBase);
10583
10595
  *
10584
10596
  * @since 2.0
10585
10597
  */
10586
- class BiWriter extends BiWriterBase {
10598
+ class BiWrite extends BiBase {
10587
10599
  /**
10588
10600
  * Binary writer, includes bitfields and strings.
10589
10601
  *
@@ -11591,6 +11603,20 @@ class BiWriter extends BiWriterBase {
11591
11603
  throw new Error("Method not implemented.");
11592
11604
  }
11593
11605
  }
11606
+ /**
11607
+ * Binary writer, includes bitfields and strings.
11608
+ *
11609
+ * @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
11610
+ * @param {BiOptions?} options - Any options to set at start
11611
+ * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
11612
+ * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
11613
+ * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
11614
+ * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
11615
+ * @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
11616
+ *
11617
+ * @since 2.0
11618
+ */
11619
+ const BiWriter = applyBinaryAliasWriter(BiWrite);
11594
11620
 
11595
11621
  /**
11596
11622
  * Isn't usable in browser.