bireader 3.1.1 → 3.1.3

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
@@ -1730,9 +1730,9 @@ class BiBase {
1730
1730
  this.errorDump = true;
1731
1731
  /**
1732
1732
  * Current buffer data.
1733
- * @type {Buffer|Uint8Array}
1733
+ * @type {Buffer|Uint8Array|null}
1734
1734
  */
1735
- this.data = [];
1735
+ this.data = null;
1736
1736
  /**
1737
1737
  * When the data buffer needs to be extended while strict mode is ``false``, this will be the amount it extends.
1738
1738
  *
@@ -1743,10 +1743,14 @@ class BiBase {
1743
1743
  * NOTE: Using ``BiWriter.get`` or ``BiWriter.return`` will now remove all data after the current write position. Use ``BiWriter.data`` to get the full buffer instead.
1744
1744
  */
1745
1745
  this.extendBufferSize = 0;
1746
+ this.fd = null;
1747
+ this.filePath = "";
1748
+ this.fsMode = "";
1746
1749
  /**
1747
1750
  * The settings that used when using the .str getter / setter
1748
1751
  */
1749
1752
  this.strDefaults = { stringType: "utf-8", terminateValue: 0x0 };
1753
+ this.maxFileSize = null;
1750
1754
  }
1751
1755
  /**
1752
1756
  * Settings for when using .str
@@ -1763,12 +1767,67 @@ class BiBase {
1763
1767
  this.strDefaults.stripNull = settings.stripNull;
1764
1768
  this.strDefaults.terminateValue = settings.terminateValue;
1765
1769
  }
1766
- isBufferOrUint8Array(obj) {
1767
- return arraybuffcheck(obj);
1770
+ /**
1771
+ * Enables expanding in reader (changes strict)
1772
+ *
1773
+ * @param {boolean} mode - Enable expanding in reader (changes strict)
1774
+ */
1775
+ writeMode(mode) {
1776
+ if (mode) {
1777
+ this.strict = false;
1778
+ return;
1779
+ }
1780
+ else {
1781
+ this.strict = true;
1782
+ return;
1783
+ }
1784
+ }
1785
+ /**
1786
+ * Dummy function, not needed on Non-Stream
1787
+ */
1788
+ open() {
1789
+ return this.size;
1790
+ }
1791
+ /**
1792
+ * Dummy function, not needed on Non-Stream
1793
+ */
1794
+ updateSize() {
1795
+ this.return;
1796
+ }
1797
+ /**
1798
+ * removes data.
1799
+ */
1800
+ close() {
1801
+ this.data = undefined;
1802
+ }
1803
+ /**
1804
+ * Dummy function, not needed on Non-Stream
1805
+ */
1806
+ read(start, length, consume = false) {
1807
+ return this.lift(start, start + length, consume);
1808
+ }
1809
+ /**
1810
+ * Dummy function, not needed on Non-Stream
1811
+ */
1812
+ write(start, data, consume = false) {
1813
+ this.insert(data, consume, start);
1814
+ return data.length;
1815
+ }
1816
+ /**
1817
+ * Dummy function, not needed on Non-Stream
1818
+ */
1819
+ commit(consume = true) {
1820
+ return consume ? 0 : 1;
1768
1821
  }
1769
1822
  extendArray(to_padd) {
1770
1823
  return extendarray(this, to_padd);
1771
1824
  }
1825
+ isBufferOrUint8Array(obj) {
1826
+ return arraybuffcheck(obj);
1827
+ }
1828
+ ///////////////////////////////
1829
+ // ENDIANNESS //
1830
+ ///////////////////////////////
1772
1831
  /**
1773
1832
  *
1774
1833
  * Change endian, defaults to little.
@@ -1822,6 +1881,9 @@ class BiBase {
1822
1881
  le() {
1823
1882
  this.endianness("little");
1824
1883
  }
1884
+ ///////////////////////////////
1885
+ // SIZE //
1886
+ ///////////////////////////////
1825
1887
  /**
1826
1888
  * Size in bytes of the current buffer.
1827
1889
  *
@@ -1870,9 +1932,9 @@ class BiBase {
1870
1932
  get lenb() {
1871
1933
  return this.sizeB;
1872
1934
  }
1873
- //
1874
- //get position
1875
- //
1935
+ ///////////////////////////////
1936
+ // POSITION //
1937
+ ///////////////////////////////
1876
1938
  /**
1877
1939
  * Get the current byte position.
1878
1940
  *
@@ -2033,9 +2095,9 @@ class BiBase {
2033
2095
  get row() {
2034
2096
  return Math.abs(Math.floor((this.offset - 1) / 16));
2035
2097
  }
2036
- //
2037
- //finishing
2038
- //
2098
+ ///////////////////////////////
2099
+ // FINISHING //
2100
+ ///////////////////////////////
2039
2101
  /**
2040
2102
  * Returns current data.
2041
2103
  *
@@ -2091,9 +2153,9 @@ class BiBase {
2091
2153
  errorDumpOn() {
2092
2154
  this.errorDump = true;
2093
2155
  }
2094
- //
2095
- //strict mode change
2096
- //
2156
+ ///////////////////////////////
2157
+ // STRICTMODE //
2158
+ ///////////////////////////////
2097
2159
  /**
2098
2160
  * Disallows extending data if position is outside of max size.
2099
2161
  */
@@ -2112,12 +2174,6 @@ class BiBase {
2112
2174
  end() {
2113
2175
  this.data = undefined;
2114
2176
  }
2115
- /**
2116
- * removes data.
2117
- */
2118
- close() {
2119
- this.data = undefined;
2120
- }
2121
2177
  /**
2122
2178
  * removes data.
2123
2179
  */
@@ -2130,9 +2186,9 @@ class BiBase {
2130
2186
  finished() {
2131
2187
  this.data = undefined;
2132
2188
  }
2133
- //
2134
- //find
2135
- //
2189
+ ///////////////////////////////
2190
+ // FIND //
2191
+ ///////////////////////////////
2136
2192
  /**
2137
2193
  * Searches for byte position of string from current read position.
2138
2194
  *
@@ -2194,7 +2250,7 @@ class BiBase {
2194
2250
  *
2195
2251
  * Does not change current read position.
2196
2252
  *
2197
- * @param {number} value - Number to search for.
2253
+ * @param {number|bigint} value - Number to search for.
2198
2254
  * @param {boolean} unsigned - If the number is unsigned (default true)
2199
2255
  * @param {endian} endian - endianness of value (default set endian).
2200
2256
  */
@@ -2240,9 +2296,9 @@ class BiBase {
2240
2296
  findDoubleFloat(value, endian) {
2241
2297
  return fDoubleFloat$1(this, value, endian);
2242
2298
  }
2243
- //
2244
- // move from current position
2245
- //
2299
+ ///////////////////////////////
2300
+ // MOVE TO //
2301
+ ///////////////////////////////
2246
2302
  /**
2247
2303
  * Aligns current byte position.
2248
2304
  *
@@ -2263,9 +2319,6 @@ class BiBase {
2263
2319
  alignRev(number) {
2264
2320
  return alignRev$1(this, number);
2265
2321
  }
2266
- //
2267
- // directly set current position
2268
- //
2269
2322
  /**
2270
2323
  * Offset current byte or bit position.
2271
2324
  *
@@ -2343,9 +2396,6 @@ class BiBase {
2343
2396
  warp(byte, bit) {
2344
2397
  return this.goto(byte, bit);
2345
2398
  }
2346
- //
2347
- // go to start
2348
- //
2349
2399
  /**
2350
2400
  * Set byte and bit position to start of data.
2351
2401
  */
@@ -2380,9 +2430,9 @@ class BiBase {
2380
2430
  this.offset = this.size;
2381
2431
  this.bitoffset = 0;
2382
2432
  }
2383
- //
2384
- //remove part of data
2385
- //
2433
+ ///////////////////////////////
2434
+ // REMOVE //
2435
+ ///////////////////////////////
2386
2436
  /**
2387
2437
  * Deletes part of data from start to current byte position unless supplied, returns removed.
2388
2438
  *
@@ -2464,9 +2514,9 @@ class BiBase {
2464
2514
  overwrite(data, consume, offset) {
2465
2515
  return addData$1(this, data, consume || false, offset || this.offset, true);
2466
2516
  }
2467
- //
2468
- // copy out
2469
- //
2517
+ ///////////////////////////////
2518
+ // COPY OUT //
2519
+ ///////////////////////////////
2470
2520
  /**
2471
2521
  * Returns part of data from current byte position to end of data unless supplied.
2472
2522
  *
@@ -2527,9 +2577,9 @@ class BiBase {
2527
2577
  wrap(length, consume) {
2528
2578
  return remove$1(this, this.offset, this.offset + (length || 0), consume || false, false);
2529
2579
  }
2530
- //
2531
- //insert
2532
- //
2580
+ ///////////////////////////////
2581
+ // INSERT //
2582
+ ///////////////////////////////
2533
2583
  /**
2534
2584
  * Inserts data into data.
2535
2585
  *
@@ -2598,9 +2648,9 @@ class BiBase {
2598
2648
  append(data, consume) {
2599
2649
  return addData$1(this, data, consume || false, this.size, false);
2600
2650
  }
2601
- //
2602
- // math
2603
- //
2651
+ ///////////////////////////////
2652
+ // MATH //
2653
+ ///////////////////////////////
2604
2654
  /**
2605
2655
  * XOR data.
2606
2656
  *
@@ -2896,9 +2946,9 @@ class BiBase {
2896
2946
  }
2897
2947
  return RSHIFT$1(this, lShiftKey, this.offset, this.offset + Length, consume || false);
2898
2948
  }
2899
- //
2900
- //bit reader
2901
- //
2949
+ ///////////////////////////////
2950
+ // BIT READER //
2951
+ ///////////////////////////////
2902
2952
  /**
2903
2953
  *
2904
2954
  * Write bits, must have at least value and number of bits.
@@ -3370,7 +3420,7 @@ class BiBase {
3370
3420
  *
3371
3421
  * @param {boolean} unsigned - if value is unsigned or not
3372
3422
  * @param {endian?} endian - ``big`` or ``little``
3373
- * @returns {number}
3423
+ * @returns {bigint}
3374
3424
  */
3375
3425
  readInt64(unsigned, endian) {
3376
3426
  return rint64$1(this, unsigned, endian);
@@ -3378,7 +3428,7 @@ class BiBase {
3378
3428
  /**
3379
3429
  * Write 64 bit integer.
3380
3430
  *
3381
- * @param {number} value - value as int
3431
+ * @param {number|bigint} value - value as int
3382
3432
  * @param {boolean} unsigned - if the value is unsigned
3383
3433
  * @param {endian} endian - ``big`` or ``little``
3384
3434
  */
@@ -3388,7 +3438,7 @@ class BiBase {
3388
3438
  /**
3389
3439
  * Write unsigned 64 bit integer.
3390
3440
  *
3391
- * @param {number} value - value as int
3441
+ * @param {number|bigint} value - value as int
3392
3442
  * @param {endian} endian - ``big`` or ``little``
3393
3443
  */
3394
3444
  writeUInt64(value, endian) {
@@ -3397,7 +3447,7 @@ class BiBase {
3397
3447
  /**
3398
3448
  * Write signed 64 bit integer.
3399
3449
  *
3400
- * @param {number} value - value as int
3450
+ * @param {number|bigint} value - value as int
3401
3451
  */
3402
3452
  writeInt64LE(value) {
3403
3453
  return this.writeInt64(value, false, "little");
@@ -3405,7 +3455,7 @@ class BiBase {
3405
3455
  /**
3406
3456
  * Write unsigned 64 bit integer.
3407
3457
  *
3408
- * @param {number} value - value as int
3458
+ * @param {number|bigint} value - value as int
3409
3459
  */
3410
3460
  writeUInt64LE(value) {
3411
3461
  return this.writeInt64(value, true, "little");
@@ -3413,7 +3463,7 @@ class BiBase {
3413
3463
  /**
3414
3464
  * Write signed 64 bit integer.
3415
3465
  *
3416
- * @param {number} value - value as int
3466
+ * @param {number|bigint} value - value as int
3417
3467
  */
3418
3468
  writeInt64BE(value) {
3419
3469
  return this.writeInt64(value, false, "big");
@@ -3421,7 +3471,7 @@ class BiBase {
3421
3471
  /**
3422
3472
  * Write unsigned 64 bit integer.
3423
3473
  *
3424
- * @param {number} value - value as int
3474
+ * @param {number|bigint} value - value as int
3425
3475
  */
3426
3476
  writeUInt64BE(value) {
3427
3477
  return this.writeInt64(value, true, "big");
@@ -3429,7 +3479,7 @@ class BiBase {
3429
3479
  /**
3430
3480
  * Read unsigned 64 bit integer.
3431
3481
  *
3432
- * @returns {number}
3482
+ * @returns {bigint}
3433
3483
  */
3434
3484
  readUInt64() {
3435
3485
  return this.readInt64(true);
@@ -3437,7 +3487,7 @@ class BiBase {
3437
3487
  /**
3438
3488
  * Read signed 64 bit integer.
3439
3489
  *
3440
- * @returns {number}
3490
+ * @returns {bigint}
3441
3491
  */
3442
3492
  readInt64BE() {
3443
3493
  return this.readInt64(false, "big");
@@ -3445,7 +3495,7 @@ class BiBase {
3445
3495
  /**
3446
3496
  * Read unsigned 64 bit integer.
3447
3497
  *
3448
- * @returns {number}
3498
+ * @returns {bigint}
3449
3499
  */
3450
3500
  readUInt64BE() {
3451
3501
  return this.readInt64(true, "big");
@@ -3453,7 +3503,7 @@ class BiBase {
3453
3503
  /**
3454
3504
  * Read signed 64 bit integer.
3455
3505
  *
3456
- * @returns {number}
3506
+ * @returns {bigint}
3457
3507
  */
3458
3508
  readInt64LE() {
3459
3509
  return this.readInt64(false, "little");
@@ -3461,7 +3511,7 @@ class BiBase {
3461
3511
  /**
3462
3512
  * Read unsigned 64 bit integer.
3463
3513
  *
3464
- * @returns {number}
3514
+ * @returns {bigint}
3465
3515
  */
3466
3516
  readUInt64LE() {
3467
3517
  return this.readInt64(true, "little");
@@ -6008,7 +6058,7 @@ function applyBinaryAliasReader(Base) {
6008
6058
  /**
6009
6059
  * Read signed 64 bit integer
6010
6060
  *
6011
- * @returns {number}
6061
+ * @returns {bigint}
6012
6062
  */
6013
6063
  get int64() {
6014
6064
  return this.readInt64();
@@ -6016,7 +6066,7 @@ function applyBinaryAliasReader(Base) {
6016
6066
  /**
6017
6067
  * Read signed 64 bit integer.
6018
6068
  *
6019
- * @returns {number}
6069
+ * @returns {bigint}
6020
6070
  */
6021
6071
  get bigint() {
6022
6072
  return this.readInt64();
@@ -6024,7 +6074,7 @@ function applyBinaryAliasReader(Base) {
6024
6074
  /**
6025
6075
  * Read signed 64 bit integer.
6026
6076
  *
6027
- * @returns {number}
6077
+ * @returns {bigint}
6028
6078
  */
6029
6079
  get quad() {
6030
6080
  return this.readInt64();
@@ -6032,7 +6082,7 @@ function applyBinaryAliasReader(Base) {
6032
6082
  /**
6033
6083
  * Read unsigned 64 bit integer.
6034
6084
  *
6035
- * @returns {number}
6085
+ * @returns {bigint}
6036
6086
  */
6037
6087
  get uint64() {
6038
6088
  return this.readInt64(true);
@@ -6040,7 +6090,7 @@ function applyBinaryAliasReader(Base) {
6040
6090
  /**
6041
6091
  * Read unsigned 64 bit integer.
6042
6092
  *
6043
- * @returns {number}
6093
+ * @returns {bigint}
6044
6094
  */
6045
6095
  get ubigint() {
6046
6096
  return this.readInt64(true);
@@ -6048,7 +6098,7 @@ function applyBinaryAliasReader(Base) {
6048
6098
  /**
6049
6099
  * Read unsigned 64 bit integer.
6050
6100
  *
6051
- * @returns {number}
6101
+ * @returns {bigint}
6052
6102
  */
6053
6103
  get uquad() {
6054
6104
  return this.readInt64(true);
@@ -6056,7 +6106,7 @@ function applyBinaryAliasReader(Base) {
6056
6106
  /**
6057
6107
  * Read signed 64 bit integer.
6058
6108
  *
6059
- * @returns {number}
6109
+ * @returns {bigint}
6060
6110
  */
6061
6111
  get int64be() {
6062
6112
  return this.readInt64(false, "big");
@@ -6064,7 +6114,7 @@ function applyBinaryAliasReader(Base) {
6064
6114
  /**
6065
6115
  * Read signed 64 bit integer.
6066
6116
  *
6067
- * @returns {number}
6117
+ * @returns {bigint}
6068
6118
  */
6069
6119
  get bigintbe() {
6070
6120
  return this.readInt64(false, "big");
@@ -6072,7 +6122,7 @@ function applyBinaryAliasReader(Base) {
6072
6122
  /**
6073
6123
  * Read signed 64 bit integer.
6074
6124
  *
6075
- * @returns {number}
6125
+ * @returns {bigint}
6076
6126
  */
6077
6127
  get quadbe() {
6078
6128
  return this.readInt64(false, "big");
@@ -6080,7 +6130,7 @@ function applyBinaryAliasReader(Base) {
6080
6130
  /**
6081
6131
  * Read unsigned 64 bit integer.
6082
6132
  *
6083
- * @returns {number}
6133
+ * @returns {bigint}
6084
6134
  */
6085
6135
  get uint64be() {
6086
6136
  return this.readInt64(true, "big");
@@ -6088,7 +6138,7 @@ function applyBinaryAliasReader(Base) {
6088
6138
  /**
6089
6139
  * Read unsigned 64 bit integer.
6090
6140
  *
6091
- * @returns {number}
6141
+ * @returns {bigint}
6092
6142
  */
6093
6143
  get ubigintbe() {
6094
6144
  return this.readInt64(true, "big");
@@ -6096,7 +6146,7 @@ function applyBinaryAliasReader(Base) {
6096
6146
  /**
6097
6147
  * Read unsigned 64 bit integer.
6098
6148
  *
6099
- * @returns {number}
6149
+ * @returns {bigint}
6100
6150
  */
6101
6151
  get uquadbe() {
6102
6152
  return this.readInt64(true, "big");
@@ -6104,7 +6154,7 @@ function applyBinaryAliasReader(Base) {
6104
6154
  /**
6105
6155
  * Read signed 64 bit integer.
6106
6156
  *
6107
- * @returns {number}
6157
+ * @returns {bigint}
6108
6158
  */
6109
6159
  get int64le() {
6110
6160
  return this.readInt64(false, "little");
@@ -6112,7 +6162,7 @@ function applyBinaryAliasReader(Base) {
6112
6162
  /**
6113
6163
  * Read signed 64 bit integer.
6114
6164
  *
6115
- * @returns {number}
6165
+ * @returns {bigint}
6116
6166
  */
6117
6167
  get bigintle() {
6118
6168
  return this.readInt64(false, "little");
@@ -6120,7 +6170,7 @@ function applyBinaryAliasReader(Base) {
6120
6170
  /**
6121
6171
  * Read signed 64 bit integer.
6122
6172
  *
6123
- * @returns {number}
6173
+ * @returns {bigint}
6124
6174
  */
6125
6175
  get quadle() {
6126
6176
  return this.readInt64(false, "little");
@@ -6128,7 +6178,7 @@ function applyBinaryAliasReader(Base) {
6128
6178
  /**
6129
6179
  * Read unsigned 64 bit integer.
6130
6180
  *
6131
- * @returns {number}
6181
+ * @returns {bigint}
6132
6182
  */
6133
6183
  get uint64le() {
6134
6184
  return this.readInt64(true, "little");
@@ -6136,7 +6186,7 @@ function applyBinaryAliasReader(Base) {
6136
6186
  /**
6137
6187
  * Read unsigned 64 bit integer.
6138
6188
  *
6139
- * @returns {number}
6189
+ * @returns {bigint}
6140
6190
  */
6141
6191
  get ubigintle() {
6142
6192
  return this.readInt64(true, "little");
@@ -6144,7 +6194,7 @@ function applyBinaryAliasReader(Base) {
6144
6194
  /**
6145
6195
  * Read unsigned 64 bit integer.
6146
6196
  *
6147
- * @returns {number}
6197
+ * @returns {bigint}
6148
6198
  */
6149
6199
  get uquadle() {
6150
6200
  return this.readInt64(true, "little");
@@ -10009,7 +10059,7 @@ function applyBinaryAliasWriter(Base) {
10009
10059
  /**
10010
10060
  * Write 64 bit integer.
10011
10061
  *
10012
- * @param {number} value - value as int
10062
+ * @param {number|bigint} value - value as int
10013
10063
  */
10014
10064
  set int64(value) {
10015
10065
  this.writeInt64(value);
@@ -10017,7 +10067,7 @@ function applyBinaryAliasWriter(Base) {
10017
10067
  /**
10018
10068
  * Write 64 bit integer.
10019
10069
  *
10020
- * @param {number} value - value as int
10070
+ * @param {number|bigint} value - value as int
10021
10071
  */
10022
10072
  set quad(value) {
10023
10073
  this.writeInt64(value);
@@ -10025,7 +10075,7 @@ function applyBinaryAliasWriter(Base) {
10025
10075
  /**
10026
10076
  * Write 64 bit integer.
10027
10077
  *
10028
- * @param {number} value - value as int
10078
+ * @param {number|bigint} value - value as int
10029
10079
  */
10030
10080
  set bigint(value) {
10031
10081
  this.writeInt64(value);
@@ -10033,7 +10083,7 @@ function applyBinaryAliasWriter(Base) {
10033
10083
  /**
10034
10084
  * Write unsigned 64 bit integer.
10035
10085
  *
10036
- * @param {number} value - value as int
10086
+ * @param {number|bigint} value - value as int
10037
10087
  */
10038
10088
  set uint64(value) {
10039
10089
  this.writeInt64(value, true);
@@ -10041,7 +10091,7 @@ function applyBinaryAliasWriter(Base) {
10041
10091
  /**
10042
10092
  * Write unsigned 64 bit integer.
10043
10093
  *
10044
- * @param {number} value - value as int
10094
+ * @param {number|bigint} value - value as int
10045
10095
  */
10046
10096
  set ubigint(value) {
10047
10097
  this.writeInt64(value, true);
@@ -10049,7 +10099,7 @@ function applyBinaryAliasWriter(Base) {
10049
10099
  /**
10050
10100
  * Write unsigned 64 bit integer.
10051
10101
  *
10052
- * @param {number} value - value as int
10102
+ * @param {number|bigint} value - value as int
10053
10103
  */
10054
10104
  set uquad(value) {
10055
10105
  this.writeInt64(value, true);
@@ -10057,7 +10107,7 @@ function applyBinaryAliasWriter(Base) {
10057
10107
  /**
10058
10108
  * Write signed 64 bit integer.
10059
10109
  *
10060
- * @param {number} value - value as int
10110
+ * @param {number|bigint} value - value as int
10061
10111
  */
10062
10112
  set int64le(value) {
10063
10113
  this.writeInt64(value, false, "little");
@@ -10065,7 +10115,7 @@ function applyBinaryAliasWriter(Base) {
10065
10115
  /**
10066
10116
  * Write signed 64 bit integer.
10067
10117
  *
10068
- * @param {number} value - value as int
10118
+ * @param {number|bigint} value - value as int
10069
10119
  */
10070
10120
  set bigintle(value) {
10071
10121
  this.writeInt64(value, false, "little");
@@ -10073,7 +10123,7 @@ function applyBinaryAliasWriter(Base) {
10073
10123
  /**
10074
10124
  * Write signed 64 bit integer.
10075
10125
  *
10076
- * @param {number} value - value as int
10126
+ * @param {number|bigint} value - value as int
10077
10127
  */
10078
10128
  set quadle(value) {
10079
10129
  this.writeInt64(value, false, "little");
@@ -10081,7 +10131,7 @@ function applyBinaryAliasWriter(Base) {
10081
10131
  /**
10082
10132
  * Write unsigned 64 bit integer.
10083
10133
  *
10084
- * @param {number} value - value as int
10134
+ * @param {number|bigint} value - value as int
10085
10135
  */
10086
10136
  set uint64le(value) {
10087
10137
  this.writeInt64(value, true, "little");
@@ -10089,7 +10139,7 @@ function applyBinaryAliasWriter(Base) {
10089
10139
  /**
10090
10140
  * Write unsigned 64 bit integer.
10091
10141
  *
10092
- * @param {number} value - value as int
10142
+ * @param {number|bigint} value - value as int
10093
10143
  */
10094
10144
  set ubigintle(value) {
10095
10145
  this.writeInt64(value, true, "little");
@@ -10097,7 +10147,7 @@ function applyBinaryAliasWriter(Base) {
10097
10147
  /**
10098
10148
  * Write unsigned 64 bit integer.
10099
10149
  *
10100
- * @param {number} value - value as int
10150
+ * @param {number|bigint} value - value as int
10101
10151
  */
10102
10152
  set uquadle(value) {
10103
10153
  this.writeInt64(value, true, "little");
@@ -10105,7 +10155,7 @@ function applyBinaryAliasWriter(Base) {
10105
10155
  /**
10106
10156
  * Write signed 64 bit integer.
10107
10157
  *
10108
- * @param {number} value - value as int
10158
+ * @param {number|bigint} value - value as int
10109
10159
  */
10110
10160
  set int64be(value) {
10111
10161
  this.writeInt64(value, false, "big");
@@ -10113,7 +10163,7 @@ function applyBinaryAliasWriter(Base) {
10113
10163
  /**
10114
10164
  * Write signed 64 bit integer.
10115
10165
  *
10116
- * @param {number} value - value as int
10166
+ * @param {number|bigint} value - value as int
10117
10167
  */
10118
10168
  set bigintbe(value) {
10119
10169
  this.writeInt64(value, false, "big");
@@ -10121,7 +10171,7 @@ function applyBinaryAliasWriter(Base) {
10121
10171
  /**
10122
10172
  * Write signed 64 bit integer.
10123
10173
  *
10124
- * @param {number} value - value as int
10174
+ * @param {number|bigint} value - value as int
10125
10175
  */
10126
10176
  set quadbe(value) {
10127
10177
  this.writeInt64(value, false, "big");
@@ -10129,7 +10179,7 @@ function applyBinaryAliasWriter(Base) {
10129
10179
  /**
10130
10180
  * Write unsigned 64 bit integer.
10131
10181
  *
10132
- * @param {number} value - value as int
10182
+ * @param {number|bigint} value - value as int
10133
10183
  */
10134
10184
  set uint64be(value) {
10135
10185
  this.writeInt64(value, true, "big");
@@ -10137,7 +10187,7 @@ function applyBinaryAliasWriter(Base) {
10137
10187
  /**
10138
10188
  * Write unsigned 64 bit integer.
10139
10189
  *
10140
- * @param {number} value - value as int
10190
+ * @param {number|bigint} value - value as int
10141
10191
  */
10142
10192
  set ubigintbe(value) {
10143
10193
  this.writeInt64(value, true, "big");
@@ -10145,7 +10195,7 @@ function applyBinaryAliasWriter(Base) {
10145
10195
  /**
10146
10196
  * Write unsigned 64 bit integer.
10147
10197
  *
10148
- * @param {number} value - value as int
10198
+ * @param {number|bigint} value - value as int
10149
10199
  */
10150
10200
  set uquadbe(value) {
10151
10201
  this.writeInt64(value, true, "big");
@@ -13314,7 +13364,7 @@ class BiBaseStreamer {
13314
13364
  /**
13315
13365
  * Current buffer chunk.
13316
13366
  *
13317
- * @type {Buffer}
13367
+ * @type {Buffer|null}
13318
13368
  */
13319
13369
  this.data = null;
13320
13370
  /**
@@ -13556,28 +13606,14 @@ class BiBaseStreamer {
13556
13606
  }
13557
13607
  }
13558
13608
  fs.ftruncateSync(this.fd, this.size + length);
13559
- //if (this.maxFileSize && this.maxFileSize > length) {
13560
- // // stream extend
13561
- // const CHUNK_SIZE = 64 * 1024;
13562
- // const buffer = Buffer.alloc(CHUNK_SIZE);
13563
- // var amount = length;
13564
- // var start = this.size;
13565
- // while (amount) {
13566
- // const toWrite = Math.min(CHUNK_SIZE, amount);
13567
- // fs.writeSync(this.fd, buffer, 0, toWrite, start);
13568
- // start += toWrite;
13569
- // amount -= toWrite;
13570
- // }
13571
- //}
13572
- //else {
13573
- // const buffer = Buffer.alloc(length);
13574
- // fs.writeSync(this.fd, buffer, 0, buffer.length, this.size);
13575
- //}
13576
13609
  this.updateSize();
13577
13610
  }
13578
13611
  isBufferOrUint8Array(obj) {
13579
13612
  return arraybuffcheck(obj);
13580
13613
  }
13614
+ ///////////////////////////////
13615
+ // ENDIANNESS //
13616
+ ///////////////////////////////
13581
13617
  /**
13582
13618
  *
13583
13619
  * Change endian, defaults to little.
@@ -13631,6 +13667,9 @@ class BiBaseStreamer {
13631
13667
  le() {
13632
13668
  this.endianness("little");
13633
13669
  }
13670
+ ///////////////////////////////
13671
+ // SIZE //
13672
+ ///////////////////////////////
13634
13673
  /**
13635
13674
  * Size in bytes of the current buffer.
13636
13675
  *
@@ -13679,9 +13718,9 @@ class BiBaseStreamer {
13679
13718
  get lenb() {
13680
13719
  return this.sizeB;
13681
13720
  }
13682
- //
13683
- //get position
13684
- //
13721
+ ///////////////////////////////
13722
+ // POSITION //
13723
+ ///////////////////////////////
13685
13724
  /**
13686
13725
  * Get the current byte position.
13687
13726
  *
@@ -13842,9 +13881,9 @@ class BiBaseStreamer {
13842
13881
  get row() {
13843
13882
  return Math.abs(Math.floor((this.offset - 1) / 16));
13844
13883
  }
13845
- //
13846
- //finishing
13847
- //
13884
+ ///////////////////////////////
13885
+ // FINISHING //
13886
+ ///////////////////////////////
13848
13887
  /**
13849
13888
  * Returns current data.
13850
13889
  *
@@ -13876,15 +13915,15 @@ class BiBaseStreamer {
13876
13915
  return this.data || Buffer.alloc(0);
13877
13916
  }
13878
13917
  /**
13879
- * Creates hex dump string. Will console log or return string if set in options.
13880
- *
13881
- * @param {object} options
13882
- * @param {hexdumpOptions?} options - hex dump options
13883
- * @param {number?} options.length - number of bytes to log, default ``192`` or end of data
13884
- * @param {number?} options.startByte - byte to start dump (default ``0``)
13885
- * @param {boolean?} options.supressUnicode - Supress unicode character preview for even columns.
13886
- * @param {boolean?} options.returnString - Returns the hex dump string instead of logging it.
13887
- */
13918
+ * Creates hex dump string. Will console log or return string if set in options.
13919
+ *
13920
+ * @param {object} options
13921
+ * @param {hexdumpOptions?} options - hex dump options
13922
+ * @param {number?} options.length - number of bytes to log, default ``192`` or end of data
13923
+ * @param {number?} options.startByte - byte to start dump (default ``0``)
13924
+ * @param {boolean?} options.supressUnicode - Supress unicode character preview for even columns.
13925
+ * @param {boolean?} options.returnString - Returns the hex dump string instead of logging it.
13926
+ */
13888
13927
  hexdump(options = {}) {
13889
13928
  return hexDump(this, options);
13890
13929
  }
@@ -13900,9 +13939,9 @@ class BiBaseStreamer {
13900
13939
  errorDumpOn() {
13901
13940
  this.errorDump = true;
13902
13941
  }
13903
- //
13904
- //strict mode change
13905
- //
13942
+ ///////////////////////////////
13943
+ // STRICTMODE //
13944
+ ///////////////////////////////
13906
13945
  /**
13907
13946
  * Disallows extending data if position is outside of max size.
13908
13947
  */
@@ -13933,9 +13972,9 @@ class BiBaseStreamer {
13933
13972
  finished() {
13934
13973
  this.data = null;
13935
13974
  }
13936
- //
13937
- //find
13938
- //
13975
+ ///////////////////////////////
13976
+ // FIND //
13977
+ ///////////////////////////////
13939
13978
  /**
13940
13979
  * Searches for byte position of string from current read position.
13941
13980
  *
@@ -13997,7 +14036,7 @@ class BiBaseStreamer {
13997
14036
  *
13998
14037
  * Does not change current read position.
13999
14038
  *
14000
- * @param {number} value - Number to search for.
14039
+ * @param {number|bigint} value - Number to search for.
14001
14040
  * @param {boolean} unsigned - If the number is unsigned (default true)
14002
14041
  * @param {endian} endian - endianness of value (default set endian).
14003
14042
  */
@@ -14043,9 +14082,9 @@ class BiBaseStreamer {
14043
14082
  findDoubleFloat(value, endian) {
14044
14083
  return fDoubleFloat(this, value, endian);
14045
14084
  }
14046
- //
14047
- // move from current position
14048
- //
14085
+ ///////////////////////////////
14086
+ // MOVE TO //
14087
+ ///////////////////////////////
14049
14088
  /**
14050
14089
  * Aligns current byte position.
14051
14090
  *
@@ -14066,9 +14105,6 @@ class BiBaseStreamer {
14066
14105
  alignRev(number) {
14067
14106
  return alignRev(this, number);
14068
14107
  }
14069
- //
14070
- // directly set current position
14071
- //
14072
14108
  /**
14073
14109
  * Offset current byte or bit position.
14074
14110
  *
@@ -14146,9 +14182,6 @@ class BiBaseStreamer {
14146
14182
  warp(byte, bit) {
14147
14183
  return this.goto(byte, bit);
14148
14184
  }
14149
- //
14150
- // go to start
14151
- //
14152
14185
  /**
14153
14186
  * Set byte and bit position to start of data.
14154
14187
  */
@@ -14183,9 +14216,9 @@ class BiBaseStreamer {
14183
14216
  this.offset = this.size;
14184
14217
  this.bitoffset = 0;
14185
14218
  }
14186
- //
14187
- //remove part of data
14188
- //
14219
+ ///////////////////////////////
14220
+ // REMOVE //
14221
+ ///////////////////////////////
14189
14222
  /**
14190
14223
  * Deletes part of data from start to current byte position unless supplied, returns removed.
14191
14224
  *
@@ -14267,9 +14300,9 @@ class BiBaseStreamer {
14267
14300
  overwrite(data, consume, offset) {
14268
14301
  return addData(this, data, consume || false, offset || this.offset, true);
14269
14302
  }
14270
- //
14271
- // copy out
14272
- //
14303
+ ///////////////////////////////
14304
+ // COPY OUT //
14305
+ ///////////////////////////////
14273
14306
  /**
14274
14307
  * Returns part of data from current byte position to end of data unless supplied.
14275
14308
  *
@@ -14330,9 +14363,9 @@ class BiBaseStreamer {
14330
14363
  wrap(length, consume) {
14331
14364
  return remove(this, this.offset, this.offset + (length || 0), consume || false, false);
14332
14365
  }
14333
- //
14334
- //insert
14335
- //
14366
+ ///////////////////////////////
14367
+ // INSERT //
14368
+ ///////////////////////////////
14336
14369
  /**
14337
14370
  * Inserts data into data.
14338
14371
  *
@@ -14401,9 +14434,9 @@ class BiBaseStreamer {
14401
14434
  append(data, consume) {
14402
14435
  return addData(this, data, consume || false, this.size, false);
14403
14436
  }
14404
- //
14405
- // math
14406
- //
14437
+ ///////////////////////////////
14438
+ // MATH //
14439
+ ///////////////////////////////
14407
14440
  /**
14408
14441
  * XOR data.
14409
14442
  *
@@ -14699,9 +14732,9 @@ class BiBaseStreamer {
14699
14732
  }
14700
14733
  return RSHIFT(this, lShiftKey, this.offset, this.offset + Length, consume || false);
14701
14734
  }
14702
- //
14703
- //bit reader
14704
- //
14735
+ ///////////////////////////////
14736
+ // BIT READER //
14737
+ ///////////////////////////////
14705
14738
  /**
14706
14739
  *
14707
14740
  * Write bits, must have at least value and number of bits.
@@ -15173,7 +15206,7 @@ class BiBaseStreamer {
15173
15206
  *
15174
15207
  * @param {boolean} unsigned - if value is unsigned or not
15175
15208
  * @param {endian?} endian - ``big`` or ``little``
15176
- * @returns {number}
15209
+ * @returns {bigint}
15177
15210
  */
15178
15211
  readInt64(unsigned, endian) {
15179
15212
  return rint64(this, unsigned, endian);
@@ -15181,7 +15214,7 @@ class BiBaseStreamer {
15181
15214
  /**
15182
15215
  * Write 64 bit integer.
15183
15216
  *
15184
- * @param {number} value - value as int
15217
+ * @param {number|bigint} value - value as int
15185
15218
  * @param {boolean} unsigned - if the value is unsigned
15186
15219
  * @param {endian} endian - ``big`` or ``little``
15187
15220
  */
@@ -15191,7 +15224,7 @@ class BiBaseStreamer {
15191
15224
  /**
15192
15225
  * Write unsigned 64 bit integer.
15193
15226
  *
15194
- * @param {number} value - value as int
15227
+ * @param {number|bigint} value - value as int
15195
15228
  * @param {endian} endian - ``big`` or ``little``
15196
15229
  */
15197
15230
  writeUInt64(value, endian) {
@@ -15200,7 +15233,7 @@ class BiBaseStreamer {
15200
15233
  /**
15201
15234
  * Write signed 64 bit integer.
15202
15235
  *
15203
- * @param {number} value - value as int
15236
+ * @param {number|bigint} value - value as int
15204
15237
  */
15205
15238
  writeInt64LE(value) {
15206
15239
  return this.writeInt64(value, false, "little");
@@ -15208,7 +15241,7 @@ class BiBaseStreamer {
15208
15241
  /**
15209
15242
  * Write unsigned 64 bit integer.
15210
15243
  *
15211
- * @param {number} value - value as int
15244
+ * @param {number|bigint} value - value as int
15212
15245
  */
15213
15246
  writeUInt64LE(value) {
15214
15247
  return this.writeInt64(value, true, "little");
@@ -15216,7 +15249,7 @@ class BiBaseStreamer {
15216
15249
  /**
15217
15250
  * Write signed 64 bit integer.
15218
15251
  *
15219
- * @param {number} value - value as int
15252
+ * @param {number|bigint} value - value as int
15220
15253
  */
15221
15254
  writeInt64BE(value) {
15222
15255
  return this.writeInt64(value, false, "big");
@@ -15224,7 +15257,7 @@ class BiBaseStreamer {
15224
15257
  /**
15225
15258
  * Write unsigned 64 bit integer.
15226
15259
  *
15227
- * @param {number} value - value as int
15260
+ * @param {number|bigint} value - value as int
15228
15261
  */
15229
15262
  writeUInt64BE(value) {
15230
15263
  return this.writeInt64(value, true, "big");
@@ -15232,7 +15265,7 @@ class BiBaseStreamer {
15232
15265
  /**
15233
15266
  * Read unsigned 64 bit integer.
15234
15267
  *
15235
- * @returns {number}
15268
+ * @returns {bigint}
15236
15269
  */
15237
15270
  readUInt64() {
15238
15271
  return this.readInt64(true);
@@ -15240,7 +15273,7 @@ class BiBaseStreamer {
15240
15273
  /**
15241
15274
  * Read signed 64 bit integer.
15242
15275
  *
15243
- * @returns {number}
15276
+ * @returns {bigint}
15244
15277
  */
15245
15278
  readInt64BE() {
15246
15279
  return this.readInt64(false, "big");
@@ -15248,7 +15281,7 @@ class BiBaseStreamer {
15248
15281
  /**
15249
15282
  * Read unsigned 64 bit integer.
15250
15283
  *
15251
- * @returns {number}
15284
+ * @returns {bigint}
15252
15285
  */
15253
15286
  readUInt64BE() {
15254
15287
  return this.readInt64(true, "big");
@@ -15256,7 +15289,7 @@ class BiBaseStreamer {
15256
15289
  /**
15257
15290
  * Read signed 64 bit integer.
15258
15291
  *
15259
- * @returns {number}
15292
+ * @returns {bigint}
15260
15293
  */
15261
15294
  readInt64LE() {
15262
15295
  return this.readInt64(false, "little");
@@ -15264,7 +15297,7 @@ class BiBaseStreamer {
15264
15297
  /**
15265
15298
  * Read unsigned 64 bit integer.
15266
15299
  *
15267
- * @returns {number}
15300
+ * @returns {bigint}
15268
15301
  */
15269
15302
  readUInt64LE() {
15270
15303
  return this.readInt64(true, "little");