bireader 1.0.46 → 1.0.48
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/lib/cjs/index.d.ts +39 -3
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +38 -12
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.d.ts +39 -3
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +38 -12
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -175,16 +175,6 @@ function addData(_this, data, consume, offset, replace) {
|
|
|
175
175
|
if (replace) {
|
|
176
176
|
needed_size = (offset || _this.offset) + data.length;
|
|
177
177
|
}
|
|
178
|
-
if (needed_size > _this.size) {
|
|
179
|
-
if (_this.strict == false) {
|
|
180
|
-
_this.extendArray(needed_size - _this.size);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
_this.errorDump ? "\x1b[31m[Error]\x1b[0m: hexdump:\n" + _this.hexdump() : "";
|
|
184
|
-
throw new Error("\x1b[33m[Strict mode]\x1b[0m: End offset outside of data: endOffset" + needed_size + " of " + _this.size);
|
|
185
|
-
}
|
|
186
|
-
_this.size = _this.data.length;
|
|
187
|
-
}
|
|
188
178
|
if (replace) {
|
|
189
179
|
const part1 = _this.data.subarray(0, needed_size - data.length);
|
|
190
180
|
const part2 = _this.data.subarray(needed_size, _this.size);
|
|
@@ -1610,7 +1600,7 @@ function wstring(_this, string, options) {
|
|
|
1610
1600
|
/**
|
|
1611
1601
|
* Binary reader, includes bitfields and strings
|
|
1612
1602
|
*
|
|
1613
|
-
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``
|
|
1603
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``bireader.data``
|
|
1614
1604
|
* @param {number} byteOffset - Byte offset to start reader (default 0)
|
|
1615
1605
|
* @param {number} bitOffset - Bit offset 0-7 to start reader (default 0)
|
|
1616
1606
|
* @param {string} endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
@@ -1626,7 +1616,7 @@ class bireader {
|
|
|
1626
1616
|
/**
|
|
1627
1617
|
* Binary reader, includes bitfields and strings
|
|
1628
1618
|
*
|
|
1629
|
-
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``
|
|
1619
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``bireader.data``
|
|
1630
1620
|
* @param {number} byteOffset - Byte offset to start reader (default 0)
|
|
1631
1621
|
* @param {number} bitOffset - Bit offset 0-7 to start reader (default 0)
|
|
1632
1622
|
* @param {string} endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
@@ -1763,6 +1753,7 @@ class bireader {
|
|
|
1763
1753
|
}
|
|
1764
1754
|
/**
|
|
1765
1755
|
* Offset current byte or bit position
|
|
1756
|
+
*
|
|
1766
1757
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1767
1758
|
*
|
|
1768
1759
|
* @param {number} bytes - Bytes to skip
|
|
@@ -1773,6 +1764,7 @@ class bireader {
|
|
|
1773
1764
|
}
|
|
1774
1765
|
/**
|
|
1775
1766
|
* Offset current byte or bit position
|
|
1767
|
+
*
|
|
1776
1768
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1777
1769
|
*
|
|
1778
1770
|
* @param {number} bytes - Bytes to skip
|
|
@@ -1786,6 +1778,7 @@ class bireader {
|
|
|
1786
1778
|
//
|
|
1787
1779
|
/**
|
|
1788
1780
|
* Change position directly to address
|
|
1781
|
+
*
|
|
1789
1782
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1790
1783
|
*
|
|
1791
1784
|
* @param {number} byte - byte to set to
|
|
@@ -1796,6 +1789,7 @@ class bireader {
|
|
|
1796
1789
|
}
|
|
1797
1790
|
/**
|
|
1798
1791
|
* Offset current byte or bit position
|
|
1792
|
+
*
|
|
1799
1793
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1800
1794
|
*
|
|
1801
1795
|
* @param {number} bytes - Bytes to skip
|
|
@@ -1806,6 +1800,7 @@ class bireader {
|
|
|
1806
1800
|
}
|
|
1807
1801
|
/**
|
|
1808
1802
|
* Change position directly to address
|
|
1803
|
+
*
|
|
1809
1804
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1810
1805
|
*
|
|
1811
1806
|
* @param {number} byte - byte to set to
|
|
@@ -1816,6 +1811,7 @@ class bireader {
|
|
|
1816
1811
|
}
|
|
1817
1812
|
/**
|
|
1818
1813
|
* Change position directly to address
|
|
1814
|
+
*
|
|
1819
1815
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1820
1816
|
*
|
|
1821
1817
|
* @param {number} byte - byte to set to
|
|
@@ -2257,6 +2253,7 @@ class bireader {
|
|
|
2257
2253
|
//
|
|
2258
2254
|
/**
|
|
2259
2255
|
* Deletes part of data from start to current byte position unless supplied, returns removed
|
|
2256
|
+
*
|
|
2260
2257
|
* Note: Errors in strict mode
|
|
2261
2258
|
*
|
|
2262
2259
|
* @param {number} startOffset - Start location (default 0)
|
|
@@ -2269,6 +2266,7 @@ class bireader {
|
|
|
2269
2266
|
}
|
|
2270
2267
|
/**
|
|
2271
2268
|
* Deletes part of data from current byte position to end, returns removed
|
|
2269
|
+
*
|
|
2272
2270
|
* Note: Errors in strict mode
|
|
2273
2271
|
*
|
|
2274
2272
|
* @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
|
|
@@ -2278,6 +2276,7 @@ class bireader {
|
|
|
2278
2276
|
}
|
|
2279
2277
|
/**
|
|
2280
2278
|
* Deletes part of data from current byte position to end, returns removed
|
|
2279
|
+
*
|
|
2281
2280
|
* Note: Errors in strict mode
|
|
2282
2281
|
*
|
|
2283
2282
|
* @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
|
|
@@ -2287,6 +2286,7 @@ class bireader {
|
|
|
2287
2286
|
}
|
|
2288
2287
|
/**
|
|
2289
2288
|
* Deletes part of data from current byte position to supplied length, returns removed
|
|
2289
|
+
*
|
|
2290
2290
|
* Note: Errors in strict mode
|
|
2291
2291
|
*
|
|
2292
2292
|
* @param {number} length - Length of data in bytes to remove
|
|
@@ -2336,6 +2336,7 @@ class bireader {
|
|
|
2336
2336
|
}
|
|
2337
2337
|
/**
|
|
2338
2338
|
* Extract data from current position to length supplied
|
|
2339
|
+
*
|
|
2339
2340
|
* Note: Does not affect supplied data
|
|
2340
2341
|
*
|
|
2341
2342
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -2347,6 +2348,7 @@ class bireader {
|
|
|
2347
2348
|
}
|
|
2348
2349
|
/**
|
|
2349
2350
|
* Extract data from current position to length supplied
|
|
2351
|
+
*
|
|
2350
2352
|
* Note: Does not affect supplied data
|
|
2351
2353
|
*
|
|
2352
2354
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -2358,6 +2360,7 @@ class bireader {
|
|
|
2358
2360
|
}
|
|
2359
2361
|
/**
|
|
2360
2362
|
* Extract data from current position to length supplied
|
|
2363
|
+
*
|
|
2361
2364
|
* Note: Does not affect supplied data
|
|
2362
2365
|
*
|
|
2363
2366
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -2372,6 +2375,7 @@ class bireader {
|
|
|
2372
2375
|
//
|
|
2373
2376
|
/**
|
|
2374
2377
|
* Inserts data into data
|
|
2378
|
+
*
|
|
2375
2379
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2376
2380
|
*
|
|
2377
2381
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2383,6 +2387,7 @@ class bireader {
|
|
|
2383
2387
|
}
|
|
2384
2388
|
/**
|
|
2385
2389
|
* Inserts data into data
|
|
2390
|
+
*
|
|
2386
2391
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2387
2392
|
*
|
|
2388
2393
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2394,6 +2399,7 @@ class bireader {
|
|
|
2394
2399
|
}
|
|
2395
2400
|
/**
|
|
2396
2401
|
* Replaces data in data
|
|
2402
|
+
*
|
|
2397
2403
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2398
2404
|
*
|
|
2399
2405
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
@@ -2405,6 +2411,7 @@ class bireader {
|
|
|
2405
2411
|
}
|
|
2406
2412
|
/**
|
|
2407
2413
|
* Replaces data in data
|
|
2414
|
+
*
|
|
2408
2415
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2409
2416
|
*
|
|
2410
2417
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
@@ -2416,6 +2423,7 @@ class bireader {
|
|
|
2416
2423
|
}
|
|
2417
2424
|
/**
|
|
2418
2425
|
* Adds data to start of supplied data
|
|
2426
|
+
*
|
|
2419
2427
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2420
2428
|
*
|
|
2421
2429
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2426,6 +2434,7 @@ class bireader {
|
|
|
2426
2434
|
}
|
|
2427
2435
|
/**
|
|
2428
2436
|
* Adds data to start of supplied data
|
|
2437
|
+
*
|
|
2429
2438
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2430
2439
|
*
|
|
2431
2440
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2436,6 +2445,7 @@ class bireader {
|
|
|
2436
2445
|
}
|
|
2437
2446
|
/**
|
|
2438
2447
|
* Adds data to end of supplied data
|
|
2448
|
+
*
|
|
2439
2449
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2440
2450
|
*
|
|
2441
2451
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2446,6 +2456,7 @@ class bireader {
|
|
|
2446
2456
|
}
|
|
2447
2457
|
/**
|
|
2448
2458
|
* Adds data to end of supplied data
|
|
2459
|
+
*
|
|
2449
2460
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2450
2461
|
*
|
|
2451
2462
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -6843,6 +6854,7 @@ class biwriter {
|
|
|
6843
6854
|
//
|
|
6844
6855
|
/**
|
|
6845
6856
|
* Deletes part of data from start to current byte position unless supplied, returns removed
|
|
6857
|
+
*
|
|
6846
6858
|
* Note: Errors in strict mode
|
|
6847
6859
|
*
|
|
6848
6860
|
* @param {number} startOffset - Start location (default 0)
|
|
@@ -6855,6 +6867,7 @@ class biwriter {
|
|
|
6855
6867
|
}
|
|
6856
6868
|
/**
|
|
6857
6869
|
* Deletes part of data from current byte position to end, returns removed
|
|
6870
|
+
*
|
|
6858
6871
|
* Note: Errors in strict mode
|
|
6859
6872
|
*
|
|
6860
6873
|
* @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
|
|
@@ -6873,6 +6886,7 @@ class biwriter {
|
|
|
6873
6886
|
}
|
|
6874
6887
|
/**
|
|
6875
6888
|
* Deletes part of data from current byte position to supplied length, returns removed
|
|
6889
|
+
*
|
|
6876
6890
|
* Note: Errors in strict mode
|
|
6877
6891
|
*
|
|
6878
6892
|
* @param {number} length - Length of data in bytes to remove
|
|
@@ -6884,6 +6898,7 @@ class biwriter {
|
|
|
6884
6898
|
}
|
|
6885
6899
|
/**
|
|
6886
6900
|
* Deletes part of data from current position to supplied length, returns removed
|
|
6901
|
+
*
|
|
6887
6902
|
* Note: Only works in strict mode
|
|
6888
6903
|
*
|
|
6889
6904
|
* @param {number} length - Length of data in bytes to remove
|
|
@@ -6922,6 +6937,7 @@ class biwriter {
|
|
|
6922
6937
|
}
|
|
6923
6938
|
/**
|
|
6924
6939
|
* Extract data from current position to length supplied
|
|
6940
|
+
*
|
|
6925
6941
|
* Note: Does not affect supplied data
|
|
6926
6942
|
*
|
|
6927
6943
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -6933,6 +6949,7 @@ class biwriter {
|
|
|
6933
6949
|
}
|
|
6934
6950
|
/**
|
|
6935
6951
|
* Extract data from current position to length supplied
|
|
6952
|
+
*
|
|
6936
6953
|
* Note: Does not affect supplied data
|
|
6937
6954
|
*
|
|
6938
6955
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -6944,6 +6961,7 @@ class biwriter {
|
|
|
6944
6961
|
}
|
|
6945
6962
|
/**
|
|
6946
6963
|
* Extract data from current position to length supplied
|
|
6964
|
+
*
|
|
6947
6965
|
* Note: Does not affect supplied data
|
|
6948
6966
|
*
|
|
6949
6967
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -6958,6 +6976,7 @@ class biwriter {
|
|
|
6958
6976
|
//
|
|
6959
6977
|
/**
|
|
6960
6978
|
* Inserts data into data
|
|
6979
|
+
*
|
|
6961
6980
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
6962
6981
|
*
|
|
6963
6982
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -6969,6 +6988,7 @@ class biwriter {
|
|
|
6969
6988
|
}
|
|
6970
6989
|
/**
|
|
6971
6990
|
* Inserts data into data
|
|
6991
|
+
*
|
|
6972
6992
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
6973
6993
|
*
|
|
6974
6994
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -6980,6 +7000,7 @@ class biwriter {
|
|
|
6980
7000
|
}
|
|
6981
7001
|
/**
|
|
6982
7002
|
* Replaces data in data
|
|
7003
|
+
*
|
|
6983
7004
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
6984
7005
|
*
|
|
6985
7006
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
@@ -6991,6 +7012,7 @@ class biwriter {
|
|
|
6991
7012
|
}
|
|
6992
7013
|
/**
|
|
6993
7014
|
* Replaces data in data
|
|
7015
|
+
*
|
|
6994
7016
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
6995
7017
|
*
|
|
6996
7018
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
@@ -7002,6 +7024,7 @@ class biwriter {
|
|
|
7002
7024
|
}
|
|
7003
7025
|
/**
|
|
7004
7026
|
* Adds data to start of supplied data
|
|
7027
|
+
*
|
|
7005
7028
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
7006
7029
|
*
|
|
7007
7030
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -7012,6 +7035,7 @@ class biwriter {
|
|
|
7012
7035
|
}
|
|
7013
7036
|
/**
|
|
7014
7037
|
* Adds data to start of supplied data
|
|
7038
|
+
*
|
|
7015
7039
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
7016
7040
|
*
|
|
7017
7041
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -7022,6 +7046,7 @@ class biwriter {
|
|
|
7022
7046
|
}
|
|
7023
7047
|
/**
|
|
7024
7048
|
* Adds data to end of supplied data
|
|
7049
|
+
*
|
|
7025
7050
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
7026
7051
|
*
|
|
7027
7052
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -7032,6 +7057,7 @@ class biwriter {
|
|
|
7032
7057
|
}
|
|
7033
7058
|
/**
|
|
7034
7059
|
* Adds data to end of supplied data
|
|
7060
|
+
*
|
|
7035
7061
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
7036
7062
|
*
|
|
7037
7063
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|