bireader 1.0.46 → 1.0.47
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 +36 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +36 -10
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.d.ts +36 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +36 -10
- package/package.json +1 -1
package/lib/esm/index.mjs
CHANGED
|
@@ -172,16 +172,6 @@ function addData(_this, data, consume, offset, replace) {
|
|
|
172
172
|
if (replace) {
|
|
173
173
|
needed_size = (offset || _this.offset) + data.length;
|
|
174
174
|
}
|
|
175
|
-
if (needed_size > _this.size) {
|
|
176
|
-
if (_this.strict == false) {
|
|
177
|
-
_this.extendArray(needed_size - _this.size);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
_this.errorDump ? "\x1b[31m[Error]\x1b[0m: hexdump:\n" + _this.hexdump() : "";
|
|
181
|
-
throw new Error("\x1b[33m[Strict mode]\x1b[0m: End offset outside of data: endOffset" + needed_size + " of " + _this.size);
|
|
182
|
-
}
|
|
183
|
-
_this.size = _this.data.length;
|
|
184
|
-
}
|
|
185
175
|
if (replace) {
|
|
186
176
|
const part1 = _this.data.subarray(0, needed_size - data.length);
|
|
187
177
|
const part2 = _this.data.subarray(needed_size, _this.size);
|
|
@@ -1760,6 +1750,7 @@ export class bireader {
|
|
|
1760
1750
|
}
|
|
1761
1751
|
/**
|
|
1762
1752
|
* Offset current byte or bit position
|
|
1753
|
+
*
|
|
1763
1754
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1764
1755
|
*
|
|
1765
1756
|
* @param {number} bytes - Bytes to skip
|
|
@@ -1770,6 +1761,7 @@ export class bireader {
|
|
|
1770
1761
|
}
|
|
1771
1762
|
/**
|
|
1772
1763
|
* Offset current byte or bit position
|
|
1764
|
+
*
|
|
1773
1765
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1774
1766
|
*
|
|
1775
1767
|
* @param {number} bytes - Bytes to skip
|
|
@@ -1783,6 +1775,7 @@ export class bireader {
|
|
|
1783
1775
|
//
|
|
1784
1776
|
/**
|
|
1785
1777
|
* Change position directly to address
|
|
1778
|
+
*
|
|
1786
1779
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1787
1780
|
*
|
|
1788
1781
|
* @param {number} byte - byte to set to
|
|
@@ -1793,6 +1786,7 @@ export class bireader {
|
|
|
1793
1786
|
}
|
|
1794
1787
|
/**
|
|
1795
1788
|
* Offset current byte or bit position
|
|
1789
|
+
*
|
|
1796
1790
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1797
1791
|
*
|
|
1798
1792
|
* @param {number} bytes - Bytes to skip
|
|
@@ -1803,6 +1797,7 @@ export class bireader {
|
|
|
1803
1797
|
}
|
|
1804
1798
|
/**
|
|
1805
1799
|
* Change position directly to address
|
|
1800
|
+
*
|
|
1806
1801
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1807
1802
|
*
|
|
1808
1803
|
* @param {number} byte - byte to set to
|
|
@@ -1813,6 +1808,7 @@ export class bireader {
|
|
|
1813
1808
|
}
|
|
1814
1809
|
/**
|
|
1815
1810
|
* Change position directly to address
|
|
1811
|
+
*
|
|
1816
1812
|
* Note: Will extend array if strict mode is off and outside of max size
|
|
1817
1813
|
*
|
|
1818
1814
|
* @param {number} byte - byte to set to
|
|
@@ -2254,6 +2250,7 @@ export class bireader {
|
|
|
2254
2250
|
//
|
|
2255
2251
|
/**
|
|
2256
2252
|
* Deletes part of data from start to current byte position unless supplied, returns removed
|
|
2253
|
+
*
|
|
2257
2254
|
* Note: Errors in strict mode
|
|
2258
2255
|
*
|
|
2259
2256
|
* @param {number} startOffset - Start location (default 0)
|
|
@@ -2266,6 +2263,7 @@ export class bireader {
|
|
|
2266
2263
|
}
|
|
2267
2264
|
/**
|
|
2268
2265
|
* Deletes part of data from current byte position to end, returns removed
|
|
2266
|
+
*
|
|
2269
2267
|
* Note: Errors in strict mode
|
|
2270
2268
|
*
|
|
2271
2269
|
* @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
|
|
@@ -2275,6 +2273,7 @@ export class bireader {
|
|
|
2275
2273
|
}
|
|
2276
2274
|
/**
|
|
2277
2275
|
* Deletes part of data from current byte position to end, returns removed
|
|
2276
|
+
*
|
|
2278
2277
|
* Note: Errors in strict mode
|
|
2279
2278
|
*
|
|
2280
2279
|
* @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
|
|
@@ -2284,6 +2283,7 @@ export class bireader {
|
|
|
2284
2283
|
}
|
|
2285
2284
|
/**
|
|
2286
2285
|
* Deletes part of data from current byte position to supplied length, returns removed
|
|
2286
|
+
*
|
|
2287
2287
|
* Note: Errors in strict mode
|
|
2288
2288
|
*
|
|
2289
2289
|
* @param {number} length - Length of data in bytes to remove
|
|
@@ -2333,6 +2333,7 @@ export class bireader {
|
|
|
2333
2333
|
}
|
|
2334
2334
|
/**
|
|
2335
2335
|
* Extract data from current position to length supplied
|
|
2336
|
+
*
|
|
2336
2337
|
* Note: Does not affect supplied data
|
|
2337
2338
|
*
|
|
2338
2339
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -2344,6 +2345,7 @@ export class bireader {
|
|
|
2344
2345
|
}
|
|
2345
2346
|
/**
|
|
2346
2347
|
* Extract data from current position to length supplied
|
|
2348
|
+
*
|
|
2347
2349
|
* Note: Does not affect supplied data
|
|
2348
2350
|
*
|
|
2349
2351
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -2355,6 +2357,7 @@ export class bireader {
|
|
|
2355
2357
|
}
|
|
2356
2358
|
/**
|
|
2357
2359
|
* Extract data from current position to length supplied
|
|
2360
|
+
*
|
|
2358
2361
|
* Note: Does not affect supplied data
|
|
2359
2362
|
*
|
|
2360
2363
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -2369,6 +2372,7 @@ export class bireader {
|
|
|
2369
2372
|
//
|
|
2370
2373
|
/**
|
|
2371
2374
|
* Inserts data into data
|
|
2375
|
+
*
|
|
2372
2376
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2373
2377
|
*
|
|
2374
2378
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2380,6 +2384,7 @@ export class bireader {
|
|
|
2380
2384
|
}
|
|
2381
2385
|
/**
|
|
2382
2386
|
* Inserts data into data
|
|
2387
|
+
*
|
|
2383
2388
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2384
2389
|
*
|
|
2385
2390
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2391,6 +2396,7 @@ export class bireader {
|
|
|
2391
2396
|
}
|
|
2392
2397
|
/**
|
|
2393
2398
|
* Replaces data in data
|
|
2399
|
+
*
|
|
2394
2400
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2395
2401
|
*
|
|
2396
2402
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
@@ -2402,6 +2408,7 @@ export class bireader {
|
|
|
2402
2408
|
}
|
|
2403
2409
|
/**
|
|
2404
2410
|
* Replaces data in data
|
|
2411
|
+
*
|
|
2405
2412
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2406
2413
|
*
|
|
2407
2414
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
@@ -2413,6 +2420,7 @@ export class bireader {
|
|
|
2413
2420
|
}
|
|
2414
2421
|
/**
|
|
2415
2422
|
* Adds data to start of supplied data
|
|
2423
|
+
*
|
|
2416
2424
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2417
2425
|
*
|
|
2418
2426
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2423,6 +2431,7 @@ export class bireader {
|
|
|
2423
2431
|
}
|
|
2424
2432
|
/**
|
|
2425
2433
|
* Adds data to start of supplied data
|
|
2434
|
+
*
|
|
2426
2435
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2427
2436
|
*
|
|
2428
2437
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2433,6 +2442,7 @@ export class bireader {
|
|
|
2433
2442
|
}
|
|
2434
2443
|
/**
|
|
2435
2444
|
* Adds data to end of supplied data
|
|
2445
|
+
*
|
|
2436
2446
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2437
2447
|
*
|
|
2438
2448
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -2443,6 +2453,7 @@ export class bireader {
|
|
|
2443
2453
|
}
|
|
2444
2454
|
/**
|
|
2445
2455
|
* Adds data to end of supplied data
|
|
2456
|
+
*
|
|
2446
2457
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
2447
2458
|
*
|
|
2448
2459
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -6839,6 +6850,7 @@ export class biwriter {
|
|
|
6839
6850
|
//
|
|
6840
6851
|
/**
|
|
6841
6852
|
* Deletes part of data from start to current byte position unless supplied, returns removed
|
|
6853
|
+
*
|
|
6842
6854
|
* Note: Errors in strict mode
|
|
6843
6855
|
*
|
|
6844
6856
|
* @param {number} startOffset - Start location (default 0)
|
|
@@ -6851,6 +6863,7 @@ export class biwriter {
|
|
|
6851
6863
|
}
|
|
6852
6864
|
/**
|
|
6853
6865
|
* Deletes part of data from current byte position to end, returns removed
|
|
6866
|
+
*
|
|
6854
6867
|
* Note: Errors in strict mode
|
|
6855
6868
|
*
|
|
6856
6869
|
* @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
|
|
@@ -6869,6 +6882,7 @@ export class biwriter {
|
|
|
6869
6882
|
}
|
|
6870
6883
|
/**
|
|
6871
6884
|
* Deletes part of data from current byte position to supplied length, returns removed
|
|
6885
|
+
*
|
|
6872
6886
|
* Note: Errors in strict mode
|
|
6873
6887
|
*
|
|
6874
6888
|
* @param {number} length - Length of data in bytes to remove
|
|
@@ -6880,6 +6894,7 @@ export class biwriter {
|
|
|
6880
6894
|
}
|
|
6881
6895
|
/**
|
|
6882
6896
|
* Deletes part of data from current position to supplied length, returns removed
|
|
6897
|
+
*
|
|
6883
6898
|
* Note: Only works in strict mode
|
|
6884
6899
|
*
|
|
6885
6900
|
* @param {number} length - Length of data in bytes to remove
|
|
@@ -6918,6 +6933,7 @@ export class biwriter {
|
|
|
6918
6933
|
}
|
|
6919
6934
|
/**
|
|
6920
6935
|
* Extract data from current position to length supplied
|
|
6936
|
+
*
|
|
6921
6937
|
* Note: Does not affect supplied data
|
|
6922
6938
|
*
|
|
6923
6939
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -6929,6 +6945,7 @@ export class biwriter {
|
|
|
6929
6945
|
}
|
|
6930
6946
|
/**
|
|
6931
6947
|
* Extract data from current position to length supplied
|
|
6948
|
+
*
|
|
6932
6949
|
* Note: Does not affect supplied data
|
|
6933
6950
|
*
|
|
6934
6951
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -6940,6 +6957,7 @@ export class biwriter {
|
|
|
6940
6957
|
}
|
|
6941
6958
|
/**
|
|
6942
6959
|
* Extract data from current position to length supplied
|
|
6960
|
+
*
|
|
6943
6961
|
* Note: Does not affect supplied data
|
|
6944
6962
|
*
|
|
6945
6963
|
* @param {number} length - Length of data in bytes to copy from current offset
|
|
@@ -6954,6 +6972,7 @@ export class biwriter {
|
|
|
6954
6972
|
//
|
|
6955
6973
|
/**
|
|
6956
6974
|
* Inserts data into data
|
|
6975
|
+
*
|
|
6957
6976
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
6958
6977
|
*
|
|
6959
6978
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -6965,6 +6984,7 @@ export class biwriter {
|
|
|
6965
6984
|
}
|
|
6966
6985
|
/**
|
|
6967
6986
|
* Inserts data into data
|
|
6987
|
+
*
|
|
6968
6988
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
6969
6989
|
*
|
|
6970
6990
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -6976,6 +6996,7 @@ export class biwriter {
|
|
|
6976
6996
|
}
|
|
6977
6997
|
/**
|
|
6978
6998
|
* Replaces data in data
|
|
6999
|
+
*
|
|
6979
7000
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
6980
7001
|
*
|
|
6981
7002
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
@@ -6987,6 +7008,7 @@ export class biwriter {
|
|
|
6987
7008
|
}
|
|
6988
7009
|
/**
|
|
6989
7010
|
* Replaces data in data
|
|
7011
|
+
*
|
|
6990
7012
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
6991
7013
|
*
|
|
6992
7014
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
@@ -6998,6 +7020,7 @@ export class biwriter {
|
|
|
6998
7020
|
}
|
|
6999
7021
|
/**
|
|
7000
7022
|
* Adds data to start of supplied data
|
|
7023
|
+
*
|
|
7001
7024
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
7002
7025
|
*
|
|
7003
7026
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -7008,6 +7031,7 @@ export class biwriter {
|
|
|
7008
7031
|
}
|
|
7009
7032
|
/**
|
|
7010
7033
|
* Adds data to start of supplied data
|
|
7034
|
+
*
|
|
7011
7035
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
7012
7036
|
*
|
|
7013
7037
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -7018,6 +7042,7 @@ export class biwriter {
|
|
|
7018
7042
|
}
|
|
7019
7043
|
/**
|
|
7020
7044
|
* Adds data to end of supplied data
|
|
7045
|
+
*
|
|
7021
7046
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
7022
7047
|
*
|
|
7023
7048
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
@@ -7028,6 +7053,7 @@ export class biwriter {
|
|
|
7028
7053
|
}
|
|
7029
7054
|
/**
|
|
7030
7055
|
* Adds data to end of supplied data
|
|
7056
|
+
*
|
|
7031
7057
|
* Note: Must be same data type as supplied data. Errors on strict mode.
|
|
7032
7058
|
*
|
|
7033
7059
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|