bireader 4.0.2 → 4.0.4

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.
@@ -1165,7 +1165,7 @@ class BiBase {
1165
1165
  /**
1166
1166
  * Get the current buffer data.
1167
1167
  *
1168
- * @type {DataType}
1168
+ * @type {ReturnMapping<DataType>}
1169
1169
  */
1170
1170
  get data() {
1171
1171
  return __classPrivateFieldGet(this, _BiBase_data, "f");
@@ -1257,10 +1257,6 @@ class BiBase {
1257
1257
  * The settings that used when using the .str getter / setter
1258
1258
  */
1259
1259
  this.strDefaults = { stringType: "utf-8", terminateValue: 0x0 };
1260
- /**
1261
- * All int64 reads will return as bigint type
1262
- */
1263
- this.enforceBigInt = null;
1264
1260
  this.wasExpanded = false;
1265
1261
  const { byteOffset, bitOffset, endianness, strict, growthIncrement, enforceBigInt, readOnly } = options;
1266
1262
  if (typeof strict != "boolean") {
@@ -1270,7 +1266,7 @@ class BiBase {
1270
1266
  this.strict = readOnly ? true : strict;
1271
1267
  this.fsMode = this.readOnly ? 'r' : 'r+';
1272
1268
  this.enforceBigInt = !!enforceBigInt;
1273
- if (this.enforceBigInt && !hasBigInt) {
1269
+ if (!hasBigInt) {
1274
1270
  this.enforceBigInt = false;
1275
1271
  }
1276
1272
  this.growthIncrement = growthIncrement;
@@ -1983,7 +1979,7 @@ class BiBase {
1983
1979
  *
1984
1980
  * Use ``.data`` instead if you want the full buffer data.
1985
1981
  *
1986
- * @returns {DataType} ``Buffer`` or ``Uint8Array``
1982
+ * @returns {ReturnMapping<DataType>} ``Buffer`` or ``Uint8Array``
1987
1983
  */
1988
1984
  get() {
1989
1985
  if (this.growthIncrement != 0 && this.wasExpanded) {
@@ -1999,7 +1995,7 @@ class BiBase {
1999
1995
  *
2000
1996
  * Use ``.data`` instead if you want the full buffer data.
2001
1997
  *
2002
- * @returns {DataType} ``Buffer`` or ``Uint8Array``
1998
+ * @returns {ReturnMapping<DataType>} ``Buffer`` or ``Uint8Array``
2003
1999
  */
2004
2000
  getFullBuffer() {
2005
2001
  return this.get();
@@ -2012,7 +2008,7 @@ class BiBase {
2012
2008
  *
2013
2009
  * Use ``.data`` instead if you want the full buffer data.
2014
2010
  *
2015
- * @returns {DataType} ``Buffer`` or ``Uint8Array``
2011
+ * @returns {ReturnMapping<DataType>} ``Buffer`` or ``Uint8Array``
2016
2012
  */
2017
2013
  return() {
2018
2014
  return this.get();
@@ -2687,7 +2683,7 @@ class BiBase {
2687
2683
  *
2688
2684
  * Note: Errors on strict mode if past end of data.
2689
2685
  *
2690
- * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to replace in data
2686
+ * @param {ReturnMapping<DataType>} data - ``Uint8Array`` or ``Buffer`` to replace in data
2691
2687
  * @param {number} offset - Offset to add it at (defaults to current position)
2692
2688
  * @param {boolean} consume - Move current byte position to end of data (default false)
2693
2689
  */
@@ -2738,7 +2734,7 @@ class BiBase {
2738
2734
  *
2739
2735
  * Note: Errors on strict mode.
2740
2736
  *
2741
- * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to replace in data
2737
+ * @param {ReturnMapping<DataType>} data - ``Uint8Array`` or ``Buffer`` to replace in data
2742
2738
  * @param {number} offset - Offset to add it at (defaults to current position)
2743
2739
  * @param {boolean} consume - Move current byte position to end of data (default false)
2744
2740
  */
@@ -2872,7 +2868,7 @@ class BiBase {
2872
2868
  *
2873
2869
  * Note: Errors on strict mode.
2874
2870
  *
2875
- * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to add to data
2871
+ * @param {ReturnMapping<DataType>} data - ``Uint8Array`` or ``Buffer`` to add to data
2876
2872
  * @param {number} offset - Byte position to add at (defaults to current position)
2877
2873
  * @param {boolean} consume - Move current byte position to end of data (default true)
2878
2874
  */
@@ -2930,7 +2926,7 @@ class BiBase {
2930
2926
  *
2931
2927
  * Note: Errors on strict mode.
2932
2928
  *
2933
- * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to add to data
2929
+ * @param {ReturnMapping<DataType>} data - ``Uint8Array`` or ``Buffer`` to add to data
2934
2930
  * @param {number} offset - Byte position to add at (defaults to current position)
2935
2931
  * @param {boolean} consume - Move current byte position to end of data (default true)
2936
2932
  */
@@ -2943,7 +2939,7 @@ class BiBase {
2943
2939
  *
2944
2940
  * Note: Errors on strict mode.
2945
2941
  *
2946
- * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to add to data
2942
+ * @param {ReturnMapping<DataType>} data - ``Uint8Array`` or ``Buffer`` to add to data
2947
2943
  * @param {boolean} consume - Move current write position to end of data (default false)
2948
2944
  */
2949
2945
  unshift(data, consume = false) {
@@ -2955,7 +2951,7 @@ class BiBase {
2955
2951
  *
2956
2952
  * Note: Errors on strict mode.
2957
2953
  *
2958
- * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to add to data
2954
+ * @param {ReturnMapping<DataType>} data - ``Uint8Array`` or ``Buffer`` to add to data
2959
2955
  * @param {boolean} consume - Move current write position to end of data (default false)
2960
2956
  */
2961
2957
  prepend(data, consume = false) {
@@ -2967,7 +2963,7 @@ class BiBase {
2967
2963
  *
2968
2964
  * Note: Errors on strict mode.
2969
2965
  *
2970
- * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to add to data
2966
+ * @param {ReturnMapping<DataType>} data - ``Uint8Array`` or ``Buffer`` to add to data
2971
2967
  * @param {boolean} consume - Move current write position to end of data (default false)
2972
2968
  */
2973
2969
  push(data, consume = false) {
@@ -2979,7 +2975,7 @@ class BiBase {
2979
2975
  *
2980
2976
  * Note: Errors on strict mode.
2981
2977
  *
2982
- * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to add to data
2978
+ * @param {ReturnMapping<DataType>} data - ``Uint8Array`` or ``Buffer`` to add to data
2983
2979
  * @param {boolean} consume - Move current write position to end of data (default false)
2984
2980
  */
2985
2981
  append(data, consume = false) {
@@ -4403,7 +4399,7 @@ class BiBase {
4403
4399
  *
4404
4400
  * Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
4405
4401
  *
4406
- * @returns {BigValue}
4402
+ * @returns {ReturnBigValueMapping<alwaysBigInt>}
4407
4403
  */
4408
4404
  readUInt64() {
4409
4405
  return this.readInt64(true);
@@ -4414,7 +4410,7 @@ class BiBase {
4414
4410
  *
4415
4411
  * Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
4416
4412
  *
4417
- * @returns {BigValue}
4413
+ * @returns {ReturnBigValueMapping<alwaysBigInt>}
4418
4414
  */
4419
4415
  readInt64BE() {
4420
4416
  return this.readInt64(false, "big");
@@ -4425,7 +4421,7 @@ class BiBase {
4425
4421
  *
4426
4422
  * Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
4427
4423
  *
4428
- * @returns {BigValue}
4424
+ * @returns {ReturnBigValueMapping<alwaysBigInt>}
4429
4425
  */
4430
4426
  readInt64LE() {
4431
4427
  return this.readInt64(false, "little");
@@ -4436,7 +4432,7 @@ class BiBase {
4436
4432
  *
4437
4433
  * Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
4438
4434
  *
4439
- * @returns {BigValue}
4435
+ * @returns {ReturnBigValueMapping<alwaysBigInt>}
4440
4436
  */
4441
4437
  readUInt64BE() {
4442
4438
  return this.readInt64(true, "big");
@@ -4447,7 +4443,7 @@ class BiBase {
4447
4443
  *
4448
4444
  * Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
4449
4445
  *
4450
- * @returns {BigValue}
4446
+ * @returns {ReturnBigValueMapping<alwaysBigInt>}
4451
4447
  */
4452
4448
  readUInt64LE() {
4453
4449
  return this.readInt64(true, "little");
@@ -5009,32 +5005,19 @@ _BiBase_offset = new WeakMap(), _BiBase_insetBit = new WeakMap(), _BiBase_data =
5009
5005
  /**
5010
5006
  * Binary reader, includes bitfields and strings.
5011
5007
  *
5012
- * @param {string|Buffer|Uint8Array} input - File path or a ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
5008
+ * @param {DataType} input - File path or a `Buffer` or `Uint8Array`. Always found in .{@link data}
5013
5009
  * @param {BiOptions?} options - Any options to set at start
5014
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start reader (default ``0``)
5015
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
5016
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
5017
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
5018
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
5019
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always be ``BigInt``.
5020
- * @param {BiOptions["writeable"]} options.writeable - Allow data writes when reading a file (default ``true`` in reader)
5010
+ * @param {BiOptions["byteOffset"]?} [options.byteOffset = 0] - Byte offset to start reader (default `0`)
5011
+ * @param {BiOptions["bitOffset"]?} [options.bitOffset = 0] - Bit offset (overrides {@link byteOffset}) (default `0`)
5012
+ * @param {BiOptions["endianness"]?} [options.endianness = "little"] - Endianness `big` or `little` (default `little`)
5013
+ * @param {BiOptions["strict"]?} [options.strict = true] - Strict mode: if `true` does not extend supplied array on outside read or write (default `true`)
5014
+ * @param {BiOptions["growthIncrement"]?} [options.growthIncrement = 1048576] - Amount of data to add when extending the buffer array when strict mode is false (default `1 MiB`)
5015
+ * @param {BiOptions["enforceBigInt"]?} [options.enforceBigInt = false] - 64 bit value reads will always return `bigint`. (default `false`)
5016
+ * @param {BiOptions["readOnly"]?} [options.readOnly = true] - Allow data writes when reading a file (default `true` in reader)
5021
5017
  *
5022
5018
  * @since 2.0
5023
5019
  */
5024
5020
  class BiReader extends BiBase {
5025
- /**
5026
- * Binary reader, includes bitfields and strings.
5027
- *
5028
- * @param {string|Buffer|Uint8Array} input - File path or a ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
5029
- * @param {BiOptions?} options - Any options to set at start
5030
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start reader (default ``0``)
5031
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
5032
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
5033
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true`` in reader)
5034
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
5035
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always be ``BigInt``.
5036
- * @param {BiOptions["readOnly"]} options.readOnly - If you want to prevent write operations (default ``true`` in reader)
5037
- */
5038
5021
  constructor(input, options = {}) {
5039
5022
  options.byteOffset = options.byteOffset ?? 0;
5040
5023
  options.bitOffset = options.bitOffset ?? 0;
@@ -8526,39 +8509,19 @@ class BiReader extends BiBase {
8526
8509
  /**
8527
8510
  * Binary writer, includes bitfields and strings.
8528
8511
  *
8529
- * @param {string|Buffer|Uint8Array} input - File path or a ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
8512
+ * @param {DataType} input - File path or a `Buffer` or `Uint8Array`. Always found in .{@link data}
8530
8513
  * @param {BiOptions?} options - Any options to set at start
8531
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
8532
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
8533
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
8534
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false`` in writer)
8535
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
8536
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always be ``BigInt``.
8514
+ * @param {BiOptions["byteOffset"]?} [options.byteOffset = 0] - Byte offset to start reader (default `0`)
8515
+ * @param {BiOptions["bitOffset"]?} [options.bitOffset = 0] - Bit offset (overrides {@link byteOffset}) (default `0`)
8516
+ * @param {BiOptions["endianness"]?} [options.endianness = "little"] - Endianness `big` or `little` (default `little`)
8517
+ * @param {BiOptions["strict"]?} [options.strict = true] - Strict mode: if `true` does not extend supplied array on outside read or write (default `true`)
8518
+ * @param {BiOptions["growthIncrement"]?} [options.growthIncrement = 1048576] - Amount of data to add when extending the buffer array when strict mode is false (default `1 MiB`)
8519
+ * @param {BiOptions["enforceBigInt"]?} [options.enforceBigInt = false] - 64 bit value reads will always return `bigint`. (default `false`)
8537
8520
  *
8538
8521
  * @since 2.0
8539
8522
  */
8540
8523
  class BiWriter extends BiBase {
8541
- /**
8542
- * Binary writer, includes bitfields and strings.
8543
- *
8544
- * @param {string|Buffer|Uint8Array} input - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
8545
- * @param {BiOptions?} options - Any options to set at start
8546
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
8547
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
8548
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
8549
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false`` in writer)
8550
- * @param {BiOptions["windowSize"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
8551
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always be ``BigInt``.
8552
- */
8553
- constructor(input, options = {
8554
- byteOffset: 0,
8555
- bitOffset: 0,
8556
- endianness: "little",
8557
- strict: false,
8558
- growthIncrement: 0,
8559
- enforceBigInt: false,
8560
- readOnly: false
8561
- }) {
8524
+ constructor(input, options = {}) {
8562
8525
  options.byteOffset = options.byteOffset ?? 0;
8563
8526
  options.bitOffset = options.bitOffset ?? 0;
8564
8527
  options.endianness = options.endianness ?? "little";
@@ -12019,12 +11982,14 @@ var fs;
12019
11982
  try {
12020
11983
  if (typeof require !== 'undefined') {
12021
11984
  if (typeof fs === "undefined") {
12022
- fs = require('fs/promises');
11985
+ const _fs = require('fs');
11986
+ fs = _fs.promises;
12023
11987
  }
12024
11988
  }
12025
11989
  else {
12026
11990
  if (typeof fs === "undefined") {
12027
- fs = await import('fs/promises');
11991
+ const _fs = await import('fs');
11992
+ fs = _fs.promises;
12028
11993
  }
12029
11994
  }
12030
11995
  }
@@ -12039,7 +12004,6 @@ async function _fileExists(filePath) {
12039
12004
  return true; // File exists
12040
12005
  }
12041
12006
  catch (error) {
12042
- // @ts-ignore
12043
12007
  return false;
12044
12008
  }
12045
12009
  }
@@ -12065,12 +12029,17 @@ class BiBaseAsync {
12065
12029
  ;
12066
12030
  /**
12067
12031
  * Get the current buffer data.
12032
+ *
12033
+ * For use in file mode!
12068
12034
  */
12069
12035
  async getData() {
12070
12036
  return await this.get();
12071
12037
  }
12072
12038
  ;
12073
- set setData(data) {
12039
+ /**
12040
+ * Set the current buffer data.
12041
+ */
12042
+ set data(data) {
12074
12043
  if (this.isBufferOrUint8Array(data)) {
12075
12044
  __classPrivateFieldSet(this, _BiBaseAsync_data, data, "f");
12076
12045
  __classPrivateFieldGet(this, _BiBaseAsync_instances, "m", _BiBaseAsync_updateView).call(this);
@@ -12155,6 +12124,9 @@ class BiBaseAsync {
12155
12124
  * Not using a file reader.
12156
12125
  */
12157
12126
  this.isMemoryMode = false;
12127
+ /**
12128
+ * If the buffer was extended and needs to be trimmed
12129
+ */
12158
12130
  this.wasExpanded = false;
12159
12131
  // ASYNC ONLY
12160
12132
  /**
@@ -12197,7 +12169,7 @@ class BiBaseAsync {
12197
12169
  this.strict = this.readOnly ? true : strict;
12198
12170
  this.fsMode = this.readOnly ? 'r' : 'r+';
12199
12171
  this.enforceBigInt = !!enforceBigInt;
12200
- if (this.enforceBigInt && !hasBigInt) {
12172
+ if (!hasBigInt) {
12201
12173
  this.enforceBigInt = false;
12202
12174
  }
12203
12175
  this.growthIncrement = growthIncrement;
@@ -12213,7 +12185,7 @@ class BiBaseAsync {
12213
12185
  this.isMemoryMode = false;
12214
12186
  }
12215
12187
  else if (this.isBufferOrUint8Array(input)) {
12216
- this.setData = input;
12188
+ this.data = input;
12217
12189
  this.isMemoryMode = true;
12218
12190
  this.filePath = null;
12219
12191
  this.windowSize = 0;
@@ -12321,7 +12293,7 @@ class BiBaseAsync {
12321
12293
  }
12322
12294
  else {
12323
12295
  if (this.isBufferOrUint8Array(data)) {
12324
- this.setData = data;
12296
+ this.data = data;
12325
12297
  }
12326
12298
  __classPrivateFieldGet(this, _BiBaseAsync_instances, "m", _BiBaseAsync_initMemory).call(this);
12327
12299
  }
@@ -13590,7 +13562,7 @@ class BiBaseAsync {
13590
13562
  data = Buffer.from(data);
13591
13563
  }
13592
13564
  }
13593
- const insertLen = data?.length ?? 0;
13565
+ const insertLen = data.length ?? 0;
13594
13566
  if (insertLen === 0) {
13595
13567
  return;
13596
13568
  }
@@ -13619,10 +13591,10 @@ class BiBaseAsync {
13619
13591
  * Note: Errors on strict mode.
13620
13592
  *
13621
13593
  * @param {DataType} data - ``Uint8Array`` or ``Buffer`` to replace in data
13622
- * @param {boolean} consume - Move current byte position to end of data (default false)
13623
13594
  * @param {number} offset - Offset to add it at (defaults to current position)
13595
+ * @param {boolean} consume - Move current byte position to end of data (default false)
13624
13596
  */
13625
- async overwrite(data, consume = false, offset = __classPrivateFieldGet(this, _BiBaseAsync_offset, "f")) {
13597
+ async overwrite(data, offset = __classPrivateFieldGet(this, _BiBaseAsync_offset, "f"), consume = false) {
13626
13598
  return await this.replace(data, offset, consume);
13627
13599
  }
13628
13600
  ;
@@ -13787,7 +13759,7 @@ class BiBaseAsync {
13787
13759
  data = Buffer.from(data);
13788
13760
  }
13789
13761
  }
13790
- const insertLen = data?.length ?? 0;
13762
+ const insertLen = data.length ?? 0;
13791
13763
  if (insertLen === 0) {
13792
13764
  return;
13793
13765
  }
@@ -15727,16 +15699,15 @@ async function _BiBaseAsync_extendArray(targetSize) {
15727
15699
  await this.flush();
15728
15700
  if (this.isMemoryMode) {
15729
15701
  const toPadd = targetSize - this.size;
15730
- var newData;
15731
15702
  if (isBuffer(__classPrivateFieldGet(this, _BiBaseAsync_data, "f"))) {
15732
- var paddbuffer = Buffer.alloc(toPadd);
15733
- newData = Buffer.concat([__classPrivateFieldGet(this, _BiBaseAsync_data, "f"), paddbuffer]);
15703
+ const paddbuffer = Buffer.alloc(toPadd);
15704
+ this.data = Buffer.concat([__classPrivateFieldGet(this, _BiBaseAsync_data, "f"), paddbuffer]);
15734
15705
  }
15735
15706
  else {
15736
- newData = new Uint8Array(this.size + toPadd);
15737
- newData.set(__classPrivateFieldGet(this, _BiBaseAsync_data, "f"));
15707
+ const newBuf = new Uint8Array(this.size + toPadd);
15708
+ newBuf.set(__classPrivateFieldGet(this, _BiBaseAsync_data, "f"));
15709
+ this.data = newBuf;
15738
15710
  }
15739
- this.setData = newData;
15740
15711
  this.size = targetSize;
15741
15712
  this.bitSize = this.size * 8;
15742
15713
  this.chunks = new Array(__classPrivateFieldGet(this, _BiBaseAsync_instances, "m", _BiBaseAsync_getNumChunks).call(this)).fill(null);
@@ -15770,7 +15741,7 @@ async function _BiBaseAsync_setFileSize(exactSize) {
15770
15741
  await this.flush();
15771
15742
  if (this.isMemoryMode) {
15772
15743
  const newData = this.data.subarray(0, exactSize);
15773
- this.setData = newData;
15744
+ this.data = newData;
15774
15745
  this.size = exactSize;
15775
15746
  this.bitSize = this.size * 8;
15776
15747
  const newNum = Math.ceil(exactSize / this.windowSize);
@@ -15975,32 +15946,20 @@ async function _BiBaseAsync_shiftTailBackward(removeOffset, removeLen, consume =
15975
15946
  /**
15976
15947
  * Async Binary reader, includes bitfields and strings.
15977
15948
  *
15978
- * @param {string|Buffer|Uint8Array} input - File path or a ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
15949
+ * @param {DataType} input - File path or a `Buffer` or `Uint8Array`.
15979
15950
  * @param {BiOptions?} options - Any options to set at start
15980
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
15981
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
15982
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
15983
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
15984
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
15985
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
15986
- * @param {BiOptions["readOnly"]} options.readOnly - If you want to prevent write operations (default true in reader)
15951
+ * @param {BiOptions["byteOffset"]?} [options.byteOffset = 0] - Byte offset to start reader (default `0`)
15952
+ * @param {BiOptions["bitOffset"]?} [options.bitOffset = 0] - Bit offset (overrides {@link byteOffset}) (default `0`)
15953
+ * @param {BiOptions["endianness"]?} [options.endianness = "little"] - Endianness `big` or `little` (default `little`)
15954
+ * @param {BiOptions["strict"]?} [options.strict = true] - Strict mode: if `true` does not extend supplied array on outside read or write (default `true`)
15955
+ * @param {BiOptions["growthIncrement"]?} [options.growthIncrement = 1048576] - Amount of data to add when extending the buffer array when strict mode is false (default `1 MiB`)
15956
+ * @param {BiOptions["enforceBigInt"]?} [options.enforceBigInt = false] - 64 bit value reads will always return `bigint`. (default `false`)
15957
+ * @param {BiOptions["readOnly"]?} [options.readOnly = true] - Allow data writes when reading a file (default `true` in reader)
15958
+ * @param {BiOptions["windowSize"]?} [options.windowSize = 4096] - Size of the chunk of a file to load per read. Set to `0` to load the whole file in one async read (default `4 KiB`)
15987
15959
  *
15988
15960
  * @since 4.0
15989
15961
  */
15990
15962
  class BiReaderAsync extends BiBaseAsync {
15991
- /**
15992
- * Async Binary reader, includes bitfields and strings.
15993
- *
15994
- * @param {string|Buffer|Uint8Array} input - File path or a ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
15995
- * @param {BiOptions?} options - Any options to set at start
15996
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
15997
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
15998
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
15999
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
16000
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false.
16001
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
16002
- * @param {BiOptions["readOnly"]} options.readOnly - If you want to prevent write operations (default true in reader)
16003
- */
16004
15963
  constructor(input, options = {}) {
16005
15964
  options.byteOffset = options.byteOffset ?? 0;
16006
15965
  options.bitOffset = options.bitOffset ?? 0;
@@ -16017,21 +15976,20 @@ class BiReaderAsync extends BiBaseAsync {
16017
15976
  }
16018
15977
  ;
16019
15978
  /**
16020
- * Creates and opens a new `BiReaderAsync`
16021
- *
16022
- * Includes bitfields and strings.
15979
+ * Creates and opens a new `BiReaderAsync`.
16023
15980
  *
16024
- * @param {string|Buffer|Uint8Array} input - File path or a ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
15981
+ * @param {DataType} input - File path or a `Buffer` or `Uint8Array`.
16025
15982
  * @param {BiOptions?} options - Any options to set at start
16026
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
16027
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
16028
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
16029
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
16030
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
16031
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
16032
- * @param {BiOptions["readonly"]} options.readonly - If you want to prevent write operations (default true in reader)
15983
+ * @param {BiOptions["byteOffset"]?} [options.byteOffset = 0] - Byte offset to start reader (default `0`)
15984
+ * @param {BiOptions["bitOffset"]?} [options.bitOffset = 0] - Bit offset (overrides {@link byteOffset}) (default `0`)
15985
+ * @param {BiOptions["endianness"]?} [options.endianness = "little"] - Endianness `big` or `little` (default `little`)
15986
+ * @param {BiOptions["strict"]?} [options.strict = true] - Strict mode: if `true` does not extend supplied array on outside read or write (default `true`)
15987
+ * @param {BiOptions["growthIncrement"]?} [options.growthIncrement = 1048576] - Amount of data to add when extending the buffer array when strict mode is false (default `1 MiB`)
15988
+ * @param {BiOptions["enforceBigInt"]?} [options.enforceBigInt = false] - 64 bit value reads will always return `bigint`. (default `false`)
15989
+ * @param {BiOptions["readOnly"]?} [options.readOnly = true] - Allow data writes when reading a file (default `true` in reader)
15990
+ * @param {BiOptions["windowSize"]?} [options.windowSize = 4096] - Size of the chunk of a file to load per read. Set to `0` to load the whole file in one async read (default `4 KiB`)
16033
15991
  *
16034
- * @returns {Promise<BiReaderAsync<DataType, hasBigInt>>}
15992
+ * @since 4.0
16035
15993
  */
16036
15994
  static async create(input, options = {}) {
16037
15995
  const instance = new BiReaderAsync(input, options);
@@ -19516,30 +19474,19 @@ class BiReaderAsync extends BiBaseAsync {
19516
19474
  /**
19517
19475
  * Async Binary writer, includes bitfields and strings.
19518
19476
  *
19519
- * @param {string|Buffer|Uint8Array} input - File path or a ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
19477
+ * @param {DataType} input - File path or a `Buffer` or ``Uint8Array`.
19520
19478
  * @param {BiOptions?} options - Any options to set at start
19521
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
19522
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
19523
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
19524
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
19525
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
19526
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
19479
+ * @param {BiOptions["byteOffset"]?} [options.byteOffset = 0] - Byte offset to start reader (default `0`)
19480
+ * @param {BiOptions["bitOffset"]?} [options.bitOffset = 0] - Bit offset (overrides {@link byteOffset}) (default `0`)
19481
+ * @param {BiOptions["endianness"]?} [options.endianness = "little"] - Endianness `big` or `little` (default `little`)
19482
+ * @param {BiOptions["strict"]?} [options.strict = true] - Strict mode: if `true` does not extend supplied array on outside read or write (default `true`)
19483
+ * @param {BiOptions["growthIncrement"]?} [options.growthIncrement = 1048576] - Amount of data to add when extending the buffer array when strict mode is false (default `1 MiB`)
19484
+ * @param {BiOptions["enforceBigInt"]?} [options.enforceBigInt = false] - 64 bit value reads will always return `bigint`. (default `false`)
19485
+ * @param {BiOptions["windowSize"]?} [options.windowSize = 4096] - Size of the chunk of a file to load per read. Set to `0` to load the whole file in one async read (default `4 KiB`)
19527
19486
  *
19528
19487
  * @since 4.0
19529
19488
  */
19530
19489
  class BiWriterAsync extends BiBaseAsync {
19531
- /**
19532
- * Async Binary writer, includes bitfields and strings.
19533
- *
19534
- * @param {string|Buffer|Uint8Array} input - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
19535
- * @param {BiOptions?} options - Any options to set at start
19536
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
19537
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
19538
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
19539
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
19540
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false.
19541
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
19542
- */
19543
19490
  constructor(input, options = {}) {
19544
19491
  options.byteOffset = options.byteOffset ?? 0;
19545
19492
  options.bitOffset = options.bitOffset ?? 0;
@@ -19559,21 +19506,19 @@ class BiWriterAsync extends BiBaseAsync {
19559
19506
  ;
19560
19507
  /**
19561
19508
  *
19562
- * Creates and opens a new `BiWriterAsync`
19509
+ * Creates and opens a new `BiWriterAsync`.
19563
19510
  *
19564
- * includes bitfields and strings.
19565
- *
19566
- * @param {string|Buffer|Uint8Array} input - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
19511
+ * @param {DataType} input - File path or a `Buffer` or ``Uint8Array`.
19567
19512
  * @param {BiOptions?} options - Any options to set at start
19568
- * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
19569
- * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
19570
- * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
19571
- * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
19572
- * @param {BiOptions["growthIncrement"]?} options.growthIncrement - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
19573
- * @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
19574
- * @param {BiOptions["writeable"]} options.writeable - Allow data writes when reading a file (default true in writer)
19513
+ * @param {BiOptions["byteOffset"]?} [options.byteOffset = 0] - Byte offset to start reader (default `0`)
19514
+ * @param {BiOptions["bitOffset"]?} [options.bitOffset = 0] - Bit offset (overrides {@link byteOffset}) (default `0`)
19515
+ * @param {BiOptions["endianness"]?} [options.endianness = "little"] - Endianness `big` or `little` (default `little`)
19516
+ * @param {BiOptions["strict"]?} [options.strict = true] - Strict mode: if `true` does not extend supplied array on outside read or write (default `true`)
19517
+ * @param {BiOptions["growthIncrement"]?} [options.growthIncrement = 1048576] - Amount of data to add when extending the buffer array when strict mode is false (default `1 MiB`)
19518
+ * @param {BiOptions["enforceBigInt"]?} [options.enforceBigInt = false] - 64 bit value reads will always return `bigint`. (default `false`)
19519
+ * @param {BiOptions["windowSize"]?} [options.windowSize = 4096] - Size of the chunk of a file to load per read. Set to `0` to load the whole file in one async read (default `4 KiB`)
19575
19520
  *
19576
- * @returns {Promise<BiWriterAsync<DataType, hasBigInt>>}
19521
+ * @returns {Promise<BiWriterAsync<DataType, alwaysBigInt>>}
19577
19522
  */
19578
19523
  static async create(input, options = {}) {
19579
19524
  const instance = new BiWriterAsync(input, options);
@@ -23017,6 +22962,7 @@ class BiWriterAsync extends BiBaseAsync {
23017
22962
  ;
23018
22963
  }
23019
22964
 
22965
+ // node common js
23020
22966
  /**
23021
22967
  * Not in use anymore.
23022
22968
  * @since 3.0
@@ -23030,7 +22976,7 @@ class bireader {
23030
22976
  /**
23031
22977
  * Not in use anymore.
23032
22978
  * @since 4.0
23033
- * @deprecated Use ``BiReader`` instead.
22979
+ * @deprecated Use ``BiReaderLegacy`` instead.
23034
22980
  */
23035
22981
  class BiReaderStream {
23036
22982
  constructor() {
@@ -23050,7 +22996,7 @@ class biwriter {
23050
22996
  /**
23051
22997
  * Not in use anymore.
23052
22998
  * @since 4.0
23053
- * @deprecated Use ``BiWriter`` instead.
22999
+ * @deprecated Use ``BiWriterLegacy`` instead.
23054
23000
  */
23055
23001
  class BiWriterStream {
23056
23002
  constructor() {
@@ -23058,7 +23004,6 @@ class BiWriterStream {
23058
23004
  }
23059
23005
  }
23060
23006
 
23061
- exports.BiBase = BiBase;
23062
23007
  exports.BiReader = BiReader;
23063
23008
  exports.BiReaderAsync = BiReaderAsync;
23064
23009
  exports.BiReaderStream = BiReaderStream;
@@ -23068,4 +23013,4 @@ exports.BiWriterStream = BiWriterStream;
23068
23013
  exports.bireader = bireader;
23069
23014
  exports.biwriter = biwriter;
23070
23015
  exports.hexdump = hexdump;
23071
- //# sourceMappingURL=index.cjs.js.map
23016
+ //# sourceMappingURL=index.js.map