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.cjs.js CHANGED
@@ -1751,9 +1751,9 @@ class BiBase {
1751
1751
  this.errorDump = true;
1752
1752
  /**
1753
1753
  * Current buffer data.
1754
- * @type {Buffer|Uint8Array}
1754
+ * @type {Buffer|Uint8Array|null}
1755
1755
  */
1756
- this.data = [];
1756
+ this.data = null;
1757
1757
  /**
1758
1758
  * When the data buffer needs to be extended while strict mode is ``false``, this will be the amount it extends.
1759
1759
  *
@@ -1764,10 +1764,14 @@ class BiBase {
1764
1764
  * 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.
1765
1765
  */
1766
1766
  this.extendBufferSize = 0;
1767
+ this.fd = null;
1768
+ this.filePath = "";
1769
+ this.fsMode = "";
1767
1770
  /**
1768
1771
  * The settings that used when using the .str getter / setter
1769
1772
  */
1770
1773
  this.strDefaults = { stringType: "utf-8", terminateValue: 0x0 };
1774
+ this.maxFileSize = null;
1771
1775
  }
1772
1776
  /**
1773
1777
  * Settings for when using .str
@@ -1784,12 +1788,67 @@ class BiBase {
1784
1788
  this.strDefaults.stripNull = settings.stripNull;
1785
1789
  this.strDefaults.terminateValue = settings.terminateValue;
1786
1790
  }
1787
- isBufferOrUint8Array(obj) {
1788
- return arraybuffcheck(obj);
1791
+ /**
1792
+ * Enables expanding in reader (changes strict)
1793
+ *
1794
+ * @param {boolean} mode - Enable expanding in reader (changes strict)
1795
+ */
1796
+ writeMode(mode) {
1797
+ if (mode) {
1798
+ this.strict = false;
1799
+ return;
1800
+ }
1801
+ else {
1802
+ this.strict = true;
1803
+ return;
1804
+ }
1805
+ }
1806
+ /**
1807
+ * Dummy function, not needed on Non-Stream
1808
+ */
1809
+ open() {
1810
+ return this.size;
1811
+ }
1812
+ /**
1813
+ * Dummy function, not needed on Non-Stream
1814
+ */
1815
+ updateSize() {
1816
+ this.return;
1817
+ }
1818
+ /**
1819
+ * removes data.
1820
+ */
1821
+ close() {
1822
+ this.data = undefined;
1823
+ }
1824
+ /**
1825
+ * Dummy function, not needed on Non-Stream
1826
+ */
1827
+ read(start, length, consume = false) {
1828
+ return this.lift(start, start + length, consume);
1829
+ }
1830
+ /**
1831
+ * Dummy function, not needed on Non-Stream
1832
+ */
1833
+ write(start, data, consume = false) {
1834
+ this.insert(data, consume, start);
1835
+ return data.length;
1836
+ }
1837
+ /**
1838
+ * Dummy function, not needed on Non-Stream
1839
+ */
1840
+ commit(consume = true) {
1841
+ return consume ? 0 : 1;
1789
1842
  }
1790
1843
  extendArray(to_padd) {
1791
1844
  return extendarray(this, to_padd);
1792
1845
  }
1846
+ isBufferOrUint8Array(obj) {
1847
+ return arraybuffcheck(obj);
1848
+ }
1849
+ ///////////////////////////////
1850
+ // ENDIANNESS //
1851
+ ///////////////////////////////
1793
1852
  /**
1794
1853
  *
1795
1854
  * Change endian, defaults to little.
@@ -1843,6 +1902,9 @@ class BiBase {
1843
1902
  le() {
1844
1903
  this.endianness("little");
1845
1904
  }
1905
+ ///////////////////////////////
1906
+ // SIZE //
1907
+ ///////////////////////////////
1846
1908
  /**
1847
1909
  * Size in bytes of the current buffer.
1848
1910
  *
@@ -1891,9 +1953,9 @@ class BiBase {
1891
1953
  get lenb() {
1892
1954
  return this.sizeB;
1893
1955
  }
1894
- //
1895
- //get position
1896
- //
1956
+ ///////////////////////////////
1957
+ // POSITION //
1958
+ ///////////////////////////////
1897
1959
  /**
1898
1960
  * Get the current byte position.
1899
1961
  *
@@ -2054,9 +2116,9 @@ class BiBase {
2054
2116
  get row() {
2055
2117
  return Math.abs(Math.floor((this.offset - 1) / 16));
2056
2118
  }
2057
- //
2058
- //finishing
2059
- //
2119
+ ///////////////////////////////
2120
+ // FINISHING //
2121
+ ///////////////////////////////
2060
2122
  /**
2061
2123
  * Returns current data.
2062
2124
  *
@@ -2112,9 +2174,9 @@ class BiBase {
2112
2174
  errorDumpOn() {
2113
2175
  this.errorDump = true;
2114
2176
  }
2115
- //
2116
- //strict mode change
2117
- //
2177
+ ///////////////////////////////
2178
+ // STRICTMODE //
2179
+ ///////////////////////////////
2118
2180
  /**
2119
2181
  * Disallows extending data if position is outside of max size.
2120
2182
  */
@@ -2133,12 +2195,6 @@ class BiBase {
2133
2195
  end() {
2134
2196
  this.data = undefined;
2135
2197
  }
2136
- /**
2137
- * removes data.
2138
- */
2139
- close() {
2140
- this.data = undefined;
2141
- }
2142
2198
  /**
2143
2199
  * removes data.
2144
2200
  */
@@ -2151,9 +2207,9 @@ class BiBase {
2151
2207
  finished() {
2152
2208
  this.data = undefined;
2153
2209
  }
2154
- //
2155
- //find
2156
- //
2210
+ ///////////////////////////////
2211
+ // FIND //
2212
+ ///////////////////////////////
2157
2213
  /**
2158
2214
  * Searches for byte position of string from current read position.
2159
2215
  *
@@ -2215,7 +2271,7 @@ class BiBase {
2215
2271
  *
2216
2272
  * Does not change current read position.
2217
2273
  *
2218
- * @param {number} value - Number to search for.
2274
+ * @param {number|bigint} value - Number to search for.
2219
2275
  * @param {boolean} unsigned - If the number is unsigned (default true)
2220
2276
  * @param {endian} endian - endianness of value (default set endian).
2221
2277
  */
@@ -2261,9 +2317,9 @@ class BiBase {
2261
2317
  findDoubleFloat(value, endian) {
2262
2318
  return fDoubleFloat$1(this, value, endian);
2263
2319
  }
2264
- //
2265
- // move from current position
2266
- //
2320
+ ///////////////////////////////
2321
+ // MOVE TO //
2322
+ ///////////////////////////////
2267
2323
  /**
2268
2324
  * Aligns current byte position.
2269
2325
  *
@@ -2284,9 +2340,6 @@ class BiBase {
2284
2340
  alignRev(number) {
2285
2341
  return alignRev$1(this, number);
2286
2342
  }
2287
- //
2288
- // directly set current position
2289
- //
2290
2343
  /**
2291
2344
  * Offset current byte or bit position.
2292
2345
  *
@@ -2364,9 +2417,6 @@ class BiBase {
2364
2417
  warp(byte, bit) {
2365
2418
  return this.goto(byte, bit);
2366
2419
  }
2367
- //
2368
- // go to start
2369
- //
2370
2420
  /**
2371
2421
  * Set byte and bit position to start of data.
2372
2422
  */
@@ -2401,9 +2451,9 @@ class BiBase {
2401
2451
  this.offset = this.size;
2402
2452
  this.bitoffset = 0;
2403
2453
  }
2404
- //
2405
- //remove part of data
2406
- //
2454
+ ///////////////////////////////
2455
+ // REMOVE //
2456
+ ///////////////////////////////
2407
2457
  /**
2408
2458
  * Deletes part of data from start to current byte position unless supplied, returns removed.
2409
2459
  *
@@ -2485,9 +2535,9 @@ class BiBase {
2485
2535
  overwrite(data, consume, offset) {
2486
2536
  return addData$1(this, data, consume || false, offset || this.offset, true);
2487
2537
  }
2488
- //
2489
- // copy out
2490
- //
2538
+ ///////////////////////////////
2539
+ // COPY OUT //
2540
+ ///////////////////////////////
2491
2541
  /**
2492
2542
  * Returns part of data from current byte position to end of data unless supplied.
2493
2543
  *
@@ -2548,9 +2598,9 @@ class BiBase {
2548
2598
  wrap(length, consume) {
2549
2599
  return remove$1(this, this.offset, this.offset + (length || 0), consume || false, false);
2550
2600
  }
2551
- //
2552
- //insert
2553
- //
2601
+ ///////////////////////////////
2602
+ // INSERT //
2603
+ ///////////////////////////////
2554
2604
  /**
2555
2605
  * Inserts data into data.
2556
2606
  *
@@ -2619,9 +2669,9 @@ class BiBase {
2619
2669
  append(data, consume) {
2620
2670
  return addData$1(this, data, consume || false, this.size, false);
2621
2671
  }
2622
- //
2623
- // math
2624
- //
2672
+ ///////////////////////////////
2673
+ // MATH //
2674
+ ///////////////////////////////
2625
2675
  /**
2626
2676
  * XOR data.
2627
2677
  *
@@ -2917,9 +2967,9 @@ class BiBase {
2917
2967
  }
2918
2968
  return RSHIFT$1(this, lShiftKey, this.offset, this.offset + Length, consume || false);
2919
2969
  }
2920
- //
2921
- //bit reader
2922
- //
2970
+ ///////////////////////////////
2971
+ // BIT READER //
2972
+ ///////////////////////////////
2923
2973
  /**
2924
2974
  *
2925
2975
  * Write bits, must have at least value and number of bits.
@@ -3391,7 +3441,7 @@ class BiBase {
3391
3441
  *
3392
3442
  * @param {boolean} unsigned - if value is unsigned or not
3393
3443
  * @param {endian?} endian - ``big`` or ``little``
3394
- * @returns {number}
3444
+ * @returns {bigint}
3395
3445
  */
3396
3446
  readInt64(unsigned, endian) {
3397
3447
  return rint64$1(this, unsigned, endian);
@@ -3399,7 +3449,7 @@ class BiBase {
3399
3449
  /**
3400
3450
  * Write 64 bit integer.
3401
3451
  *
3402
- * @param {number} value - value as int
3452
+ * @param {number|bigint} value - value as int
3403
3453
  * @param {boolean} unsigned - if the value is unsigned
3404
3454
  * @param {endian} endian - ``big`` or ``little``
3405
3455
  */
@@ -3409,7 +3459,7 @@ class BiBase {
3409
3459
  /**
3410
3460
  * Write unsigned 64 bit integer.
3411
3461
  *
3412
- * @param {number} value - value as int
3462
+ * @param {number|bigint} value - value as int
3413
3463
  * @param {endian} endian - ``big`` or ``little``
3414
3464
  */
3415
3465
  writeUInt64(value, endian) {
@@ -3418,7 +3468,7 @@ class BiBase {
3418
3468
  /**
3419
3469
  * Write signed 64 bit integer.
3420
3470
  *
3421
- * @param {number} value - value as int
3471
+ * @param {number|bigint} value - value as int
3422
3472
  */
3423
3473
  writeInt64LE(value) {
3424
3474
  return this.writeInt64(value, false, "little");
@@ -3426,7 +3476,7 @@ class BiBase {
3426
3476
  /**
3427
3477
  * Write unsigned 64 bit integer.
3428
3478
  *
3429
- * @param {number} value - value as int
3479
+ * @param {number|bigint} value - value as int
3430
3480
  */
3431
3481
  writeUInt64LE(value) {
3432
3482
  return this.writeInt64(value, true, "little");
@@ -3434,7 +3484,7 @@ class BiBase {
3434
3484
  /**
3435
3485
  * Write signed 64 bit integer.
3436
3486
  *
3437
- * @param {number} value - value as int
3487
+ * @param {number|bigint} value - value as int
3438
3488
  */
3439
3489
  writeInt64BE(value) {
3440
3490
  return this.writeInt64(value, false, "big");
@@ -3442,7 +3492,7 @@ class BiBase {
3442
3492
  /**
3443
3493
  * Write unsigned 64 bit integer.
3444
3494
  *
3445
- * @param {number} value - value as int
3495
+ * @param {number|bigint} value - value as int
3446
3496
  */
3447
3497
  writeUInt64BE(value) {
3448
3498
  return this.writeInt64(value, true, "big");
@@ -3450,7 +3500,7 @@ class BiBase {
3450
3500
  /**
3451
3501
  * Read unsigned 64 bit integer.
3452
3502
  *
3453
- * @returns {number}
3503
+ * @returns {bigint}
3454
3504
  */
3455
3505
  readUInt64() {
3456
3506
  return this.readInt64(true);
@@ -3458,7 +3508,7 @@ class BiBase {
3458
3508
  /**
3459
3509
  * Read signed 64 bit integer.
3460
3510
  *
3461
- * @returns {number}
3511
+ * @returns {bigint}
3462
3512
  */
3463
3513
  readInt64BE() {
3464
3514
  return this.readInt64(false, "big");
@@ -3466,7 +3516,7 @@ class BiBase {
3466
3516
  /**
3467
3517
  * Read unsigned 64 bit integer.
3468
3518
  *
3469
- * @returns {number}
3519
+ * @returns {bigint}
3470
3520
  */
3471
3521
  readUInt64BE() {
3472
3522
  return this.readInt64(true, "big");
@@ -3474,7 +3524,7 @@ class BiBase {
3474
3524
  /**
3475
3525
  * Read signed 64 bit integer.
3476
3526
  *
3477
- * @returns {number}
3527
+ * @returns {bigint}
3478
3528
  */
3479
3529
  readInt64LE() {
3480
3530
  return this.readInt64(false, "little");
@@ -3482,7 +3532,7 @@ class BiBase {
3482
3532
  /**
3483
3533
  * Read unsigned 64 bit integer.
3484
3534
  *
3485
- * @returns {number}
3535
+ * @returns {bigint}
3486
3536
  */
3487
3537
  readUInt64LE() {
3488
3538
  return this.readInt64(true, "little");
@@ -6029,7 +6079,7 @@ function applyBinaryAliasReader(Base) {
6029
6079
  /**
6030
6080
  * Read signed 64 bit integer
6031
6081
  *
6032
- * @returns {number}
6082
+ * @returns {bigint}
6033
6083
  */
6034
6084
  get int64() {
6035
6085
  return this.readInt64();
@@ -6037,7 +6087,7 @@ function applyBinaryAliasReader(Base) {
6037
6087
  /**
6038
6088
  * Read signed 64 bit integer.
6039
6089
  *
6040
- * @returns {number}
6090
+ * @returns {bigint}
6041
6091
  */
6042
6092
  get bigint() {
6043
6093
  return this.readInt64();
@@ -6045,7 +6095,7 @@ function applyBinaryAliasReader(Base) {
6045
6095
  /**
6046
6096
  * Read signed 64 bit integer.
6047
6097
  *
6048
- * @returns {number}
6098
+ * @returns {bigint}
6049
6099
  */
6050
6100
  get quad() {
6051
6101
  return this.readInt64();
@@ -6053,7 +6103,7 @@ function applyBinaryAliasReader(Base) {
6053
6103
  /**
6054
6104
  * Read unsigned 64 bit integer.
6055
6105
  *
6056
- * @returns {number}
6106
+ * @returns {bigint}
6057
6107
  */
6058
6108
  get uint64() {
6059
6109
  return this.readInt64(true);
@@ -6061,7 +6111,7 @@ function applyBinaryAliasReader(Base) {
6061
6111
  /**
6062
6112
  * Read unsigned 64 bit integer.
6063
6113
  *
6064
- * @returns {number}
6114
+ * @returns {bigint}
6065
6115
  */
6066
6116
  get ubigint() {
6067
6117
  return this.readInt64(true);
@@ -6069,7 +6119,7 @@ function applyBinaryAliasReader(Base) {
6069
6119
  /**
6070
6120
  * Read unsigned 64 bit integer.
6071
6121
  *
6072
- * @returns {number}
6122
+ * @returns {bigint}
6073
6123
  */
6074
6124
  get uquad() {
6075
6125
  return this.readInt64(true);
@@ -6077,7 +6127,7 @@ function applyBinaryAliasReader(Base) {
6077
6127
  /**
6078
6128
  * Read signed 64 bit integer.
6079
6129
  *
6080
- * @returns {number}
6130
+ * @returns {bigint}
6081
6131
  */
6082
6132
  get int64be() {
6083
6133
  return this.readInt64(false, "big");
@@ -6085,7 +6135,7 @@ function applyBinaryAliasReader(Base) {
6085
6135
  /**
6086
6136
  * Read signed 64 bit integer.
6087
6137
  *
6088
- * @returns {number}
6138
+ * @returns {bigint}
6089
6139
  */
6090
6140
  get bigintbe() {
6091
6141
  return this.readInt64(false, "big");
@@ -6093,7 +6143,7 @@ function applyBinaryAliasReader(Base) {
6093
6143
  /**
6094
6144
  * Read signed 64 bit integer.
6095
6145
  *
6096
- * @returns {number}
6146
+ * @returns {bigint}
6097
6147
  */
6098
6148
  get quadbe() {
6099
6149
  return this.readInt64(false, "big");
@@ -6101,7 +6151,7 @@ function applyBinaryAliasReader(Base) {
6101
6151
  /**
6102
6152
  * Read unsigned 64 bit integer.
6103
6153
  *
6104
- * @returns {number}
6154
+ * @returns {bigint}
6105
6155
  */
6106
6156
  get uint64be() {
6107
6157
  return this.readInt64(true, "big");
@@ -6109,7 +6159,7 @@ function applyBinaryAliasReader(Base) {
6109
6159
  /**
6110
6160
  * Read unsigned 64 bit integer.
6111
6161
  *
6112
- * @returns {number}
6162
+ * @returns {bigint}
6113
6163
  */
6114
6164
  get ubigintbe() {
6115
6165
  return this.readInt64(true, "big");
@@ -6117,7 +6167,7 @@ function applyBinaryAliasReader(Base) {
6117
6167
  /**
6118
6168
  * Read unsigned 64 bit integer.
6119
6169
  *
6120
- * @returns {number}
6170
+ * @returns {bigint}
6121
6171
  */
6122
6172
  get uquadbe() {
6123
6173
  return this.readInt64(true, "big");
@@ -6125,7 +6175,7 @@ function applyBinaryAliasReader(Base) {
6125
6175
  /**
6126
6176
  * Read signed 64 bit integer.
6127
6177
  *
6128
- * @returns {number}
6178
+ * @returns {bigint}
6129
6179
  */
6130
6180
  get int64le() {
6131
6181
  return this.readInt64(false, "little");
@@ -6133,7 +6183,7 @@ function applyBinaryAliasReader(Base) {
6133
6183
  /**
6134
6184
  * Read signed 64 bit integer.
6135
6185
  *
6136
- * @returns {number}
6186
+ * @returns {bigint}
6137
6187
  */
6138
6188
  get bigintle() {
6139
6189
  return this.readInt64(false, "little");
@@ -6141,7 +6191,7 @@ function applyBinaryAliasReader(Base) {
6141
6191
  /**
6142
6192
  * Read signed 64 bit integer.
6143
6193
  *
6144
- * @returns {number}
6194
+ * @returns {bigint}
6145
6195
  */
6146
6196
  get quadle() {
6147
6197
  return this.readInt64(false, "little");
@@ -6149,7 +6199,7 @@ function applyBinaryAliasReader(Base) {
6149
6199
  /**
6150
6200
  * Read unsigned 64 bit integer.
6151
6201
  *
6152
- * @returns {number}
6202
+ * @returns {bigint}
6153
6203
  */
6154
6204
  get uint64le() {
6155
6205
  return this.readInt64(true, "little");
@@ -6157,7 +6207,7 @@ function applyBinaryAliasReader(Base) {
6157
6207
  /**
6158
6208
  * Read unsigned 64 bit integer.
6159
6209
  *
6160
- * @returns {number}
6210
+ * @returns {bigint}
6161
6211
  */
6162
6212
  get ubigintle() {
6163
6213
  return this.readInt64(true, "little");
@@ -6165,7 +6215,7 @@ function applyBinaryAliasReader(Base) {
6165
6215
  /**
6166
6216
  * Read unsigned 64 bit integer.
6167
6217
  *
6168
- * @returns {number}
6218
+ * @returns {bigint}
6169
6219
  */
6170
6220
  get uquadle() {
6171
6221
  return this.readInt64(true, "little");
@@ -10030,7 +10080,7 @@ function applyBinaryAliasWriter(Base) {
10030
10080
  /**
10031
10081
  * Write 64 bit integer.
10032
10082
  *
10033
- * @param {number} value - value as int
10083
+ * @param {number|bigint} value - value as int
10034
10084
  */
10035
10085
  set int64(value) {
10036
10086
  this.writeInt64(value);
@@ -10038,7 +10088,7 @@ function applyBinaryAliasWriter(Base) {
10038
10088
  /**
10039
10089
  * Write 64 bit integer.
10040
10090
  *
10041
- * @param {number} value - value as int
10091
+ * @param {number|bigint} value - value as int
10042
10092
  */
10043
10093
  set quad(value) {
10044
10094
  this.writeInt64(value);
@@ -10046,7 +10096,7 @@ function applyBinaryAliasWriter(Base) {
10046
10096
  /**
10047
10097
  * Write 64 bit integer.
10048
10098
  *
10049
- * @param {number} value - value as int
10099
+ * @param {number|bigint} value - value as int
10050
10100
  */
10051
10101
  set bigint(value) {
10052
10102
  this.writeInt64(value);
@@ -10054,7 +10104,7 @@ function applyBinaryAliasWriter(Base) {
10054
10104
  /**
10055
10105
  * Write unsigned 64 bit integer.
10056
10106
  *
10057
- * @param {number} value - value as int
10107
+ * @param {number|bigint} value - value as int
10058
10108
  */
10059
10109
  set uint64(value) {
10060
10110
  this.writeInt64(value, true);
@@ -10062,7 +10112,7 @@ function applyBinaryAliasWriter(Base) {
10062
10112
  /**
10063
10113
  * Write unsigned 64 bit integer.
10064
10114
  *
10065
- * @param {number} value - value as int
10115
+ * @param {number|bigint} value - value as int
10066
10116
  */
10067
10117
  set ubigint(value) {
10068
10118
  this.writeInt64(value, true);
@@ -10070,7 +10120,7 @@ function applyBinaryAliasWriter(Base) {
10070
10120
  /**
10071
10121
  * Write unsigned 64 bit integer.
10072
10122
  *
10073
- * @param {number} value - value as int
10123
+ * @param {number|bigint} value - value as int
10074
10124
  */
10075
10125
  set uquad(value) {
10076
10126
  this.writeInt64(value, true);
@@ -10078,7 +10128,7 @@ function applyBinaryAliasWriter(Base) {
10078
10128
  /**
10079
10129
  * Write signed 64 bit integer.
10080
10130
  *
10081
- * @param {number} value - value as int
10131
+ * @param {number|bigint} value - value as int
10082
10132
  */
10083
10133
  set int64le(value) {
10084
10134
  this.writeInt64(value, false, "little");
@@ -10086,7 +10136,7 @@ function applyBinaryAliasWriter(Base) {
10086
10136
  /**
10087
10137
  * Write signed 64 bit integer.
10088
10138
  *
10089
- * @param {number} value - value as int
10139
+ * @param {number|bigint} value - value as int
10090
10140
  */
10091
10141
  set bigintle(value) {
10092
10142
  this.writeInt64(value, false, "little");
@@ -10094,7 +10144,7 @@ function applyBinaryAliasWriter(Base) {
10094
10144
  /**
10095
10145
  * Write signed 64 bit integer.
10096
10146
  *
10097
- * @param {number} value - value as int
10147
+ * @param {number|bigint} value - value as int
10098
10148
  */
10099
10149
  set quadle(value) {
10100
10150
  this.writeInt64(value, false, "little");
@@ -10102,7 +10152,7 @@ function applyBinaryAliasWriter(Base) {
10102
10152
  /**
10103
10153
  * Write unsigned 64 bit integer.
10104
10154
  *
10105
- * @param {number} value - value as int
10155
+ * @param {number|bigint} value - value as int
10106
10156
  */
10107
10157
  set uint64le(value) {
10108
10158
  this.writeInt64(value, true, "little");
@@ -10110,7 +10160,7 @@ function applyBinaryAliasWriter(Base) {
10110
10160
  /**
10111
10161
  * Write unsigned 64 bit integer.
10112
10162
  *
10113
- * @param {number} value - value as int
10163
+ * @param {number|bigint} value - value as int
10114
10164
  */
10115
10165
  set ubigintle(value) {
10116
10166
  this.writeInt64(value, true, "little");
@@ -10118,7 +10168,7 @@ function applyBinaryAliasWriter(Base) {
10118
10168
  /**
10119
10169
  * Write unsigned 64 bit integer.
10120
10170
  *
10121
- * @param {number} value - value as int
10171
+ * @param {number|bigint} value - value as int
10122
10172
  */
10123
10173
  set uquadle(value) {
10124
10174
  this.writeInt64(value, true, "little");
@@ -10126,7 +10176,7 @@ function applyBinaryAliasWriter(Base) {
10126
10176
  /**
10127
10177
  * Write signed 64 bit integer.
10128
10178
  *
10129
- * @param {number} value - value as int
10179
+ * @param {number|bigint} value - value as int
10130
10180
  */
10131
10181
  set int64be(value) {
10132
10182
  this.writeInt64(value, false, "big");
@@ -10134,7 +10184,7 @@ function applyBinaryAliasWriter(Base) {
10134
10184
  /**
10135
10185
  * Write signed 64 bit integer.
10136
10186
  *
10137
- * @param {number} value - value as int
10187
+ * @param {number|bigint} value - value as int
10138
10188
  */
10139
10189
  set bigintbe(value) {
10140
10190
  this.writeInt64(value, false, "big");
@@ -10142,7 +10192,7 @@ function applyBinaryAliasWriter(Base) {
10142
10192
  /**
10143
10193
  * Write signed 64 bit integer.
10144
10194
  *
10145
- * @param {number} value - value as int
10195
+ * @param {number|bigint} value - value as int
10146
10196
  */
10147
10197
  set quadbe(value) {
10148
10198
  this.writeInt64(value, false, "big");
@@ -10150,7 +10200,7 @@ function applyBinaryAliasWriter(Base) {
10150
10200
  /**
10151
10201
  * Write unsigned 64 bit integer.
10152
10202
  *
10153
- * @param {number} value - value as int
10203
+ * @param {number|bigint} value - value as int
10154
10204
  */
10155
10205
  set uint64be(value) {
10156
10206
  this.writeInt64(value, true, "big");
@@ -10158,7 +10208,7 @@ function applyBinaryAliasWriter(Base) {
10158
10208
  /**
10159
10209
  * Write unsigned 64 bit integer.
10160
10210
  *
10161
- * @param {number} value - value as int
10211
+ * @param {number|bigint} value - value as int
10162
10212
  */
10163
10213
  set ubigintbe(value) {
10164
10214
  this.writeInt64(value, true, "big");
@@ -10166,7 +10216,7 @@ function applyBinaryAliasWriter(Base) {
10166
10216
  /**
10167
10217
  * Write unsigned 64 bit integer.
10168
10218
  *
10169
- * @param {number} value - value as int
10219
+ * @param {number|bigint} value - value as int
10170
10220
  */
10171
10221
  set uquadbe(value) {
10172
10222
  this.writeInt64(value, true, "big");
@@ -13335,7 +13385,7 @@ class BiBaseStreamer {
13335
13385
  /**
13336
13386
  * Current buffer chunk.
13337
13387
  *
13338
- * @type {Buffer}
13388
+ * @type {Buffer|null}
13339
13389
  */
13340
13390
  this.data = null;
13341
13391
  /**
@@ -13577,28 +13627,14 @@ class BiBaseStreamer {
13577
13627
  }
13578
13628
  }
13579
13629
  fs.ftruncateSync(this.fd, this.size + length);
13580
- //if (this.maxFileSize && this.maxFileSize > length) {
13581
- // // stream extend
13582
- // const CHUNK_SIZE = 64 * 1024;
13583
- // const buffer = Buffer.alloc(CHUNK_SIZE);
13584
- // var amount = length;
13585
- // var start = this.size;
13586
- // while (amount) {
13587
- // const toWrite = Math.min(CHUNK_SIZE, amount);
13588
- // fs.writeSync(this.fd, buffer, 0, toWrite, start);
13589
- // start += toWrite;
13590
- // amount -= toWrite;
13591
- // }
13592
- //}
13593
- //else {
13594
- // const buffer = Buffer.alloc(length);
13595
- // fs.writeSync(this.fd, buffer, 0, buffer.length, this.size);
13596
- //}
13597
13630
  this.updateSize();
13598
13631
  }
13599
13632
  isBufferOrUint8Array(obj) {
13600
13633
  return arraybuffcheck(obj);
13601
13634
  }
13635
+ ///////////////////////////////
13636
+ // ENDIANNESS //
13637
+ ///////////////////////////////
13602
13638
  /**
13603
13639
  *
13604
13640
  * Change endian, defaults to little.
@@ -13652,6 +13688,9 @@ class BiBaseStreamer {
13652
13688
  le() {
13653
13689
  this.endianness("little");
13654
13690
  }
13691
+ ///////////////////////////////
13692
+ // SIZE //
13693
+ ///////////////////////////////
13655
13694
  /**
13656
13695
  * Size in bytes of the current buffer.
13657
13696
  *
@@ -13700,9 +13739,9 @@ class BiBaseStreamer {
13700
13739
  get lenb() {
13701
13740
  return this.sizeB;
13702
13741
  }
13703
- //
13704
- //get position
13705
- //
13742
+ ///////////////////////////////
13743
+ // POSITION //
13744
+ ///////////////////////////////
13706
13745
  /**
13707
13746
  * Get the current byte position.
13708
13747
  *
@@ -13863,9 +13902,9 @@ class BiBaseStreamer {
13863
13902
  get row() {
13864
13903
  return Math.abs(Math.floor((this.offset - 1) / 16));
13865
13904
  }
13866
- //
13867
- //finishing
13868
- //
13905
+ ///////////////////////////////
13906
+ // FINISHING //
13907
+ ///////////////////////////////
13869
13908
  /**
13870
13909
  * Returns current data.
13871
13910
  *
@@ -13897,15 +13936,15 @@ class BiBaseStreamer {
13897
13936
  return this.data || Buffer.alloc(0);
13898
13937
  }
13899
13938
  /**
13900
- * Creates hex dump string. Will console log or return string if set in options.
13901
- *
13902
- * @param {object} options
13903
- * @param {hexdumpOptions?} options - hex dump options
13904
- * @param {number?} options.length - number of bytes to log, default ``192`` or end of data
13905
- * @param {number?} options.startByte - byte to start dump (default ``0``)
13906
- * @param {boolean?} options.supressUnicode - Supress unicode character preview for even columns.
13907
- * @param {boolean?} options.returnString - Returns the hex dump string instead of logging it.
13908
- */
13939
+ * Creates hex dump string. Will console log or return string if set in options.
13940
+ *
13941
+ * @param {object} options
13942
+ * @param {hexdumpOptions?} options - hex dump options
13943
+ * @param {number?} options.length - number of bytes to log, default ``192`` or end of data
13944
+ * @param {number?} options.startByte - byte to start dump (default ``0``)
13945
+ * @param {boolean?} options.supressUnicode - Supress unicode character preview for even columns.
13946
+ * @param {boolean?} options.returnString - Returns the hex dump string instead of logging it.
13947
+ */
13909
13948
  hexdump(options = {}) {
13910
13949
  return hexDump(this, options);
13911
13950
  }
@@ -13921,9 +13960,9 @@ class BiBaseStreamer {
13921
13960
  errorDumpOn() {
13922
13961
  this.errorDump = true;
13923
13962
  }
13924
- //
13925
- //strict mode change
13926
- //
13963
+ ///////////////////////////////
13964
+ // STRICTMODE //
13965
+ ///////////////////////////////
13927
13966
  /**
13928
13967
  * Disallows extending data if position is outside of max size.
13929
13968
  */
@@ -13954,9 +13993,9 @@ class BiBaseStreamer {
13954
13993
  finished() {
13955
13994
  this.data = null;
13956
13995
  }
13957
- //
13958
- //find
13959
- //
13996
+ ///////////////////////////////
13997
+ // FIND //
13998
+ ///////////////////////////////
13960
13999
  /**
13961
14000
  * Searches for byte position of string from current read position.
13962
14001
  *
@@ -14018,7 +14057,7 @@ class BiBaseStreamer {
14018
14057
  *
14019
14058
  * Does not change current read position.
14020
14059
  *
14021
- * @param {number} value - Number to search for.
14060
+ * @param {number|bigint} value - Number to search for.
14022
14061
  * @param {boolean} unsigned - If the number is unsigned (default true)
14023
14062
  * @param {endian} endian - endianness of value (default set endian).
14024
14063
  */
@@ -14064,9 +14103,9 @@ class BiBaseStreamer {
14064
14103
  findDoubleFloat(value, endian) {
14065
14104
  return fDoubleFloat(this, value, endian);
14066
14105
  }
14067
- //
14068
- // move from current position
14069
- //
14106
+ ///////////////////////////////
14107
+ // MOVE TO //
14108
+ ///////////////////////////////
14070
14109
  /**
14071
14110
  * Aligns current byte position.
14072
14111
  *
@@ -14087,9 +14126,6 @@ class BiBaseStreamer {
14087
14126
  alignRev(number) {
14088
14127
  return alignRev(this, number);
14089
14128
  }
14090
- //
14091
- // directly set current position
14092
- //
14093
14129
  /**
14094
14130
  * Offset current byte or bit position.
14095
14131
  *
@@ -14167,9 +14203,6 @@ class BiBaseStreamer {
14167
14203
  warp(byte, bit) {
14168
14204
  return this.goto(byte, bit);
14169
14205
  }
14170
- //
14171
- // go to start
14172
- //
14173
14206
  /**
14174
14207
  * Set byte and bit position to start of data.
14175
14208
  */
@@ -14204,9 +14237,9 @@ class BiBaseStreamer {
14204
14237
  this.offset = this.size;
14205
14238
  this.bitoffset = 0;
14206
14239
  }
14207
- //
14208
- //remove part of data
14209
- //
14240
+ ///////////////////////////////
14241
+ // REMOVE //
14242
+ ///////////////////////////////
14210
14243
  /**
14211
14244
  * Deletes part of data from start to current byte position unless supplied, returns removed.
14212
14245
  *
@@ -14288,9 +14321,9 @@ class BiBaseStreamer {
14288
14321
  overwrite(data, consume, offset) {
14289
14322
  return addData(this, data, consume || false, offset || this.offset, true);
14290
14323
  }
14291
- //
14292
- // copy out
14293
- //
14324
+ ///////////////////////////////
14325
+ // COPY OUT //
14326
+ ///////////////////////////////
14294
14327
  /**
14295
14328
  * Returns part of data from current byte position to end of data unless supplied.
14296
14329
  *
@@ -14351,9 +14384,9 @@ class BiBaseStreamer {
14351
14384
  wrap(length, consume) {
14352
14385
  return remove(this, this.offset, this.offset + (length || 0), consume || false, false);
14353
14386
  }
14354
- //
14355
- //insert
14356
- //
14387
+ ///////////////////////////////
14388
+ // INSERT //
14389
+ ///////////////////////////////
14357
14390
  /**
14358
14391
  * Inserts data into data.
14359
14392
  *
@@ -14422,9 +14455,9 @@ class BiBaseStreamer {
14422
14455
  append(data, consume) {
14423
14456
  return addData(this, data, consume || false, this.size, false);
14424
14457
  }
14425
- //
14426
- // math
14427
- //
14458
+ ///////////////////////////////
14459
+ // MATH //
14460
+ ///////////////////////////////
14428
14461
  /**
14429
14462
  * XOR data.
14430
14463
  *
@@ -14720,9 +14753,9 @@ class BiBaseStreamer {
14720
14753
  }
14721
14754
  return RSHIFT(this, lShiftKey, this.offset, this.offset + Length, consume || false);
14722
14755
  }
14723
- //
14724
- //bit reader
14725
- //
14756
+ ///////////////////////////////
14757
+ // BIT READER //
14758
+ ///////////////////////////////
14726
14759
  /**
14727
14760
  *
14728
14761
  * Write bits, must have at least value and number of bits.
@@ -15194,7 +15227,7 @@ class BiBaseStreamer {
15194
15227
  *
15195
15228
  * @param {boolean} unsigned - if value is unsigned or not
15196
15229
  * @param {endian?} endian - ``big`` or ``little``
15197
- * @returns {number}
15230
+ * @returns {bigint}
15198
15231
  */
15199
15232
  readInt64(unsigned, endian) {
15200
15233
  return rint64(this, unsigned, endian);
@@ -15202,7 +15235,7 @@ class BiBaseStreamer {
15202
15235
  /**
15203
15236
  * Write 64 bit integer.
15204
15237
  *
15205
- * @param {number} value - value as int
15238
+ * @param {number|bigint} value - value as int
15206
15239
  * @param {boolean} unsigned - if the value is unsigned
15207
15240
  * @param {endian} endian - ``big`` or ``little``
15208
15241
  */
@@ -15212,7 +15245,7 @@ class BiBaseStreamer {
15212
15245
  /**
15213
15246
  * Write unsigned 64 bit integer.
15214
15247
  *
15215
- * @param {number} value - value as int
15248
+ * @param {number|bigint} value - value as int
15216
15249
  * @param {endian} endian - ``big`` or ``little``
15217
15250
  */
15218
15251
  writeUInt64(value, endian) {
@@ -15221,7 +15254,7 @@ class BiBaseStreamer {
15221
15254
  /**
15222
15255
  * Write signed 64 bit integer.
15223
15256
  *
15224
- * @param {number} value - value as int
15257
+ * @param {number|bigint} value - value as int
15225
15258
  */
15226
15259
  writeInt64LE(value) {
15227
15260
  return this.writeInt64(value, false, "little");
@@ -15229,7 +15262,7 @@ class BiBaseStreamer {
15229
15262
  /**
15230
15263
  * Write unsigned 64 bit integer.
15231
15264
  *
15232
- * @param {number} value - value as int
15265
+ * @param {number|bigint} value - value as int
15233
15266
  */
15234
15267
  writeUInt64LE(value) {
15235
15268
  return this.writeInt64(value, true, "little");
@@ -15237,7 +15270,7 @@ class BiBaseStreamer {
15237
15270
  /**
15238
15271
  * Write signed 64 bit integer.
15239
15272
  *
15240
- * @param {number} value - value as int
15273
+ * @param {number|bigint} value - value as int
15241
15274
  */
15242
15275
  writeInt64BE(value) {
15243
15276
  return this.writeInt64(value, false, "big");
@@ -15245,7 +15278,7 @@ class BiBaseStreamer {
15245
15278
  /**
15246
15279
  * Write unsigned 64 bit integer.
15247
15280
  *
15248
- * @param {number} value - value as int
15281
+ * @param {number|bigint} value - value as int
15249
15282
  */
15250
15283
  writeUInt64BE(value) {
15251
15284
  return this.writeInt64(value, true, "big");
@@ -15253,7 +15286,7 @@ class BiBaseStreamer {
15253
15286
  /**
15254
15287
  * Read unsigned 64 bit integer.
15255
15288
  *
15256
- * @returns {number}
15289
+ * @returns {bigint}
15257
15290
  */
15258
15291
  readUInt64() {
15259
15292
  return this.readInt64(true);
@@ -15261,7 +15294,7 @@ class BiBaseStreamer {
15261
15294
  /**
15262
15295
  * Read signed 64 bit integer.
15263
15296
  *
15264
- * @returns {number}
15297
+ * @returns {bigint}
15265
15298
  */
15266
15299
  readInt64BE() {
15267
15300
  return this.readInt64(false, "big");
@@ -15269,7 +15302,7 @@ class BiBaseStreamer {
15269
15302
  /**
15270
15303
  * Read unsigned 64 bit integer.
15271
15304
  *
15272
- * @returns {number}
15305
+ * @returns {bigint}
15273
15306
  */
15274
15307
  readUInt64BE() {
15275
15308
  return this.readInt64(true, "big");
@@ -15277,7 +15310,7 @@ class BiBaseStreamer {
15277
15310
  /**
15278
15311
  * Read signed 64 bit integer.
15279
15312
  *
15280
- * @returns {number}
15313
+ * @returns {bigint}
15281
15314
  */
15282
15315
  readInt64LE() {
15283
15316
  return this.readInt64(false, "little");
@@ -15285,7 +15318,7 @@ class BiBaseStreamer {
15285
15318
  /**
15286
15319
  * Read unsigned 64 bit integer.
15287
15320
  *
15288
- * @returns {number}
15321
+ * @returns {bigint}
15289
15322
  */
15290
15323
  readUInt64LE() {
15291
15324
  return this.readInt64(true, "little");