bireader 3.1.9 → 3.1.10
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/README.md +5 -4
- package/dist/index.browser.d.ts +117 -58
- package/dist/index.browser.js +105 -37
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.d.ts +228 -116
- package/dist/index.cjs.js +206 -75
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +228 -116
- package/dist/index.esm.d.ts +228 -116
- package/dist/index.esm.js +206 -75
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ Supported data types:
|
|
|
17
17
|
## What's New?
|
|
18
18
|
|
|
19
19
|
### v3
|
|
20
|
+
* Added ``enforceBigInt`` option for always returning a ``BigInt`` type on 64 bit reads, otherwise will return a ``number`` if integer safe.
|
|
20
21
|
* Added Browser, Node CommonJS and Node ESM modules.
|
|
21
22
|
* Added new ``BiReaderStream`` and ``BiWriterStream`` (Node only) that works without loading the whole file into memory. See [documention](#bistreams) for how to use.
|
|
22
23
|
* Added ``.deleteFile()`` and ``.renameFile(filePath)``.
|
|
@@ -311,14 +312,14 @@ Common functions for setup, movement, manipulation and math shared by both.
|
|
|
311
312
|
<tr>
|
|
312
313
|
<tr>
|
|
313
314
|
<td>Name</td>
|
|
314
|
-
<td>new BiReader(<b>data</b>, {byteOffset, bitOffset, endianess, strict, extendBufferSize})</td>
|
|
315
|
-
<td align="center" rowspan="2"><b>Buffer or Uint8Array</b>, byte offset (default 0), bit offset (default 0), endian big or little (default little), strict mode true to restrict extending initially supplied data (default true for reader, false for writer), extended Buffer size amount.
|
|
315
|
+
<td>new BiReader(<b>data</b>, {byteOffset, bitOffset, endianess, strict, extendBufferSize, enforceBigInt})</td>
|
|
316
|
+
<td align="center" rowspan="2"><b>Buffer or Uint8Array</b>, byte offset (default 0), bit offset (default 0), endian big or little (default little), strict mode true to restrict extending initially supplied data (default true for reader, false for writer), extended Buffer size amount, always return BigInt values on 64 bit reads.
|
|
316
317
|
</td>
|
|
317
|
-
<td rowspan="2">Start with new Constructor.<br><br><b>Note:</b> Supplied data can always be found with <b>.data</b>.<br><br><b>Writing data note:</b> while BiWriter can be created with a 0 length Uint8Array or Buffer, each new value write will create a new array and concat the two. For large data writes this will lead to a degraded performance. It's best to supply a larger than needed buffer when creating the Writer and use <b>.trim()</b> after you're finished. You can
|
|
318
|
+
<td rowspan="2">Start with new Constructor.<br><br><b>Note:</b> Supplied data can always be found with <b>.data</b>.<br><br><b>Writing data note:</b> while BiWriter can be created with a 0 length Uint8Array or Buffer, each new value write will create a new array and concat the two. For large data writes this will lead to a degraded performance. It's best to supply a larger than needed buffer when creating the Writer and use <b>.trim()</b> after you're finished. <br><br> You can set the <b>extendBufferSize</b> value to always extend by a fixed amount when reaching the end. This will also change the logic for <b>.return</b> and <b>.get</b> to trim the remining data from the current position for you. Use <b>.data</b> instead if you want to get the whole padded buffer array.</td>
|
|
318
319
|
</tr>
|
|
319
320
|
<tr>
|
|
320
321
|
<td>Name</td>
|
|
321
|
-
<td>new BiWriter(data, {byteOffset, bitOffset, endianess, strict, extendBufferSize})</td>
|
|
322
|
+
<td>new BiWriter(data, {byteOffset, bitOffset, endianess, strict, extendBufferSize, enforceBigInt})</td>
|
|
322
323
|
</tr>
|
|
323
324
|
<tr>
|
|
324
325
|
<td>Name</td>
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ type BiOptions = {
|
|
|
22
22
|
* Amount of data to add when extending the buffer array when strict mode is false. Note: Changes login in ``.get`` and ``.return``.
|
|
23
23
|
*/
|
|
24
24
|
extendBufferSize?: number;
|
|
25
|
+
/**
|
|
26
|
+
* When reading a 64 bit value, the reader checks if the value is safe for a ``number`` type and convert it.
|
|
27
|
+
*
|
|
28
|
+
* Set this to ``true`` if you wish for it to always stay a ``BigInt``.
|
|
29
|
+
*/
|
|
30
|
+
enforceBigInt?: boolean;
|
|
25
31
|
};
|
|
26
32
|
type hexdumpOptions = {
|
|
27
33
|
/**
|
|
@@ -140,6 +146,7 @@ declare class BiBase {
|
|
|
140
146
|
*/
|
|
141
147
|
private strDefaults;
|
|
142
148
|
maxFileSize: number | null;
|
|
149
|
+
enforceBigInt: boolean;
|
|
143
150
|
constructor();
|
|
144
151
|
/**
|
|
145
152
|
* Settings for when using .str
|
|
@@ -1282,11 +1289,13 @@ declare class BiBase {
|
|
|
1282
1289
|
/**
|
|
1283
1290
|
* Read signed 64 bit integer.
|
|
1284
1291
|
*
|
|
1292
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
1293
|
+
*
|
|
1285
1294
|
* @param {boolean} unsigned - if value is unsigned or not
|
|
1286
1295
|
* @param {endian?} endian - ``big`` or ``little``
|
|
1287
|
-
* @returns {
|
|
1296
|
+
* @returns {BigValue}
|
|
1288
1297
|
*/
|
|
1289
|
-
readInt64(unsigned?: boolean, endian?: endian):
|
|
1298
|
+
readInt64(unsigned?: boolean, endian?: endian): BigValue;
|
|
1290
1299
|
/**
|
|
1291
1300
|
* Write 64 bit integer.
|
|
1292
1301
|
*
|
|
@@ -1329,33 +1338,43 @@ declare class BiBase {
|
|
|
1329
1338
|
/**
|
|
1330
1339
|
* Read unsigned 64 bit integer.
|
|
1331
1340
|
*
|
|
1332
|
-
*
|
|
1341
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
1342
|
+
*
|
|
1343
|
+
* @returns {BigValue}
|
|
1333
1344
|
*/
|
|
1334
|
-
readUInt64():
|
|
1345
|
+
readUInt64(): BigValue;
|
|
1335
1346
|
/**
|
|
1336
1347
|
* Read signed 64 bit integer.
|
|
1337
1348
|
*
|
|
1338
|
-
*
|
|
1349
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
1350
|
+
*
|
|
1351
|
+
* @returns {BigValue}
|
|
1339
1352
|
*/
|
|
1340
|
-
readInt64BE():
|
|
1353
|
+
readInt64BE(): BigValue;
|
|
1341
1354
|
/**
|
|
1342
1355
|
* Read unsigned 64 bit integer.
|
|
1343
1356
|
*
|
|
1344
|
-
*
|
|
1357
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
1358
|
+
*
|
|
1359
|
+
* @returns {BigValue}
|
|
1345
1360
|
*/
|
|
1346
|
-
readUInt64BE():
|
|
1361
|
+
readUInt64BE(): BigValue;
|
|
1347
1362
|
/**
|
|
1348
1363
|
* Read signed 64 bit integer.
|
|
1349
1364
|
*
|
|
1350
|
-
*
|
|
1365
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
1366
|
+
*
|
|
1367
|
+
* @returns {BigValue}
|
|
1351
1368
|
*/
|
|
1352
|
-
readInt64LE():
|
|
1369
|
+
readInt64LE(): BigValue;
|
|
1353
1370
|
/**
|
|
1354
1371
|
* Read unsigned 64 bit integer.
|
|
1355
1372
|
*
|
|
1356
|
-
*
|
|
1373
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
1374
|
+
*
|
|
1375
|
+
* @returns {BigValue}
|
|
1357
1376
|
*/
|
|
1358
|
-
readUInt64LE():
|
|
1377
|
+
readUInt64LE(): BigValue;
|
|
1359
1378
|
/**
|
|
1360
1379
|
* Read double float.
|
|
1361
1380
|
*
|
|
@@ -1427,11 +1446,12 @@ declare class BiBase {
|
|
|
1427
1446
|
*
|
|
1428
1447
|
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
|
|
1429
1448
|
* @param {BiOptions?} options - Any options to set at start
|
|
1430
|
-
* @param {
|
|
1431
|
-
* @param {
|
|
1432
|
-
* @param {
|
|
1433
|
-
* @param {
|
|
1434
|
-
* @param {
|
|
1449
|
+
* @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
|
|
1450
|
+
* @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
|
|
1451
|
+
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
1452
|
+
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
1453
|
+
* @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
|
|
1454
|
+
* @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
|
|
1435
1455
|
*
|
|
1436
1456
|
* @since 2.0
|
|
1437
1457
|
*/
|
|
@@ -1441,11 +1461,12 @@ declare class BiReader extends BiBase {
|
|
|
1441
1461
|
*
|
|
1442
1462
|
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
|
|
1443
1463
|
* @param {BiOptions?} options - Any options to set at start
|
|
1444
|
-
* @param {
|
|
1445
|
-
* @param {
|
|
1446
|
-
* @param {
|
|
1447
|
-
* @param {
|
|
1448
|
-
* @param {
|
|
1464
|
+
* @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
|
|
1465
|
+
* @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
|
|
1466
|
+
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
1467
|
+
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
1468
|
+
* @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
|
|
1469
|
+
* @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
|
|
1449
1470
|
*/
|
|
1450
1471
|
constructor(data: Buffer | Uint8Array, options?: BiOptions);
|
|
1451
1472
|
/**
|
|
@@ -3376,111 +3397,147 @@ declare class BiReader extends BiBase {
|
|
|
3376
3397
|
/**
|
|
3377
3398
|
* Read signed 64 bit integer
|
|
3378
3399
|
*
|
|
3379
|
-
*
|
|
3400
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3401
|
+
*
|
|
3402
|
+
* @returns {BigValue}
|
|
3380
3403
|
*/
|
|
3381
|
-
get int64():
|
|
3404
|
+
get int64(): BigValue;
|
|
3382
3405
|
/**
|
|
3383
3406
|
* Read signed 64 bit integer.
|
|
3384
3407
|
*
|
|
3385
|
-
*
|
|
3408
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3409
|
+
*
|
|
3410
|
+
* @returns {BigValue}
|
|
3386
3411
|
*/
|
|
3387
|
-
get bigint():
|
|
3412
|
+
get bigint(): BigValue;
|
|
3388
3413
|
/**
|
|
3389
3414
|
* Read signed 64 bit integer.
|
|
3390
3415
|
*
|
|
3391
|
-
*
|
|
3416
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3417
|
+
*
|
|
3418
|
+
* @returns {BigValue}
|
|
3392
3419
|
*/
|
|
3393
|
-
get quad():
|
|
3420
|
+
get quad(): BigValue;
|
|
3394
3421
|
/**
|
|
3395
3422
|
* Read unsigned 64 bit integer.
|
|
3396
3423
|
*
|
|
3397
|
-
*
|
|
3424
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3425
|
+
*
|
|
3426
|
+
* @returns {BigValue}
|
|
3398
3427
|
*/
|
|
3399
|
-
get uint64():
|
|
3428
|
+
get uint64(): BigValue;
|
|
3400
3429
|
/**
|
|
3401
3430
|
* Read unsigned 64 bit integer.
|
|
3402
3431
|
*
|
|
3403
|
-
*
|
|
3432
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3433
|
+
*
|
|
3434
|
+
* @returns {BigValue}
|
|
3404
3435
|
*/
|
|
3405
|
-
get ubigint():
|
|
3436
|
+
get ubigint(): BigValue;
|
|
3406
3437
|
/**
|
|
3407
3438
|
* Read unsigned 64 bit integer.
|
|
3408
3439
|
*
|
|
3409
|
-
*
|
|
3440
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3441
|
+
*
|
|
3442
|
+
* @returns {BigValue}
|
|
3410
3443
|
*/
|
|
3411
|
-
get uquad():
|
|
3444
|
+
get uquad(): BigValue;
|
|
3412
3445
|
/**
|
|
3413
3446
|
* Read signed 64 bit integer.
|
|
3414
3447
|
*
|
|
3415
|
-
*
|
|
3448
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3449
|
+
*
|
|
3450
|
+
* @returns {BigValue}
|
|
3416
3451
|
*/
|
|
3417
|
-
get int64be():
|
|
3452
|
+
get int64be(): BigValue;
|
|
3418
3453
|
/**
|
|
3419
3454
|
* Read signed 64 bit integer.
|
|
3420
3455
|
*
|
|
3421
|
-
*
|
|
3456
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3457
|
+
*
|
|
3458
|
+
* @returns {BigValue}
|
|
3422
3459
|
*/
|
|
3423
|
-
get bigintbe():
|
|
3460
|
+
get bigintbe(): BigValue;
|
|
3424
3461
|
/**
|
|
3425
3462
|
* Read signed 64 bit integer.
|
|
3426
3463
|
*
|
|
3427
|
-
*
|
|
3464
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3465
|
+
*
|
|
3466
|
+
* @returns {BigValue}
|
|
3428
3467
|
*/
|
|
3429
|
-
get quadbe():
|
|
3468
|
+
get quadbe(): BigValue;
|
|
3430
3469
|
/**
|
|
3431
3470
|
* Read unsigned 64 bit integer.
|
|
3432
3471
|
*
|
|
3433
|
-
*
|
|
3472
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3473
|
+
*
|
|
3474
|
+
* @returns {BigValue}
|
|
3434
3475
|
*/
|
|
3435
|
-
get uint64be():
|
|
3476
|
+
get uint64be(): BigValue;
|
|
3436
3477
|
/**
|
|
3437
3478
|
* Read unsigned 64 bit integer.
|
|
3438
3479
|
*
|
|
3439
|
-
*
|
|
3480
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3481
|
+
*
|
|
3482
|
+
* @returns {BigValue}
|
|
3440
3483
|
*/
|
|
3441
|
-
get ubigintbe():
|
|
3484
|
+
get ubigintbe(): BigValue;
|
|
3442
3485
|
/**
|
|
3443
3486
|
* Read unsigned 64 bit integer.
|
|
3444
3487
|
*
|
|
3445
|
-
*
|
|
3488
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3489
|
+
*
|
|
3490
|
+
* @returns {BigValue}
|
|
3446
3491
|
*/
|
|
3447
|
-
get uquadbe():
|
|
3492
|
+
get uquadbe(): BigValue;
|
|
3448
3493
|
/**
|
|
3449
3494
|
* Read signed 64 bit integer.
|
|
3450
3495
|
*
|
|
3451
|
-
*
|
|
3496
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3497
|
+
*
|
|
3498
|
+
* @returns {BigValue}
|
|
3452
3499
|
*/
|
|
3453
|
-
get int64le():
|
|
3500
|
+
get int64le(): BigValue;
|
|
3454
3501
|
/**
|
|
3455
3502
|
* Read signed 64 bit integer.
|
|
3456
3503
|
*
|
|
3457
|
-
*
|
|
3504
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3505
|
+
*
|
|
3506
|
+
* @returns {BigValue}
|
|
3458
3507
|
*/
|
|
3459
|
-
get bigintle():
|
|
3508
|
+
get bigintle(): BigValue;
|
|
3460
3509
|
/**
|
|
3461
3510
|
* Read signed 64 bit integer.
|
|
3462
3511
|
*
|
|
3463
|
-
*
|
|
3512
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3513
|
+
*
|
|
3514
|
+
* @returns {BigValue}
|
|
3464
3515
|
*/
|
|
3465
|
-
get quadle():
|
|
3516
|
+
get quadle(): BigValue;
|
|
3466
3517
|
/**
|
|
3467
3518
|
* Read unsigned 64 bit integer.
|
|
3468
3519
|
*
|
|
3469
|
-
*
|
|
3520
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3521
|
+
*
|
|
3522
|
+
* @returns {BigValue}
|
|
3470
3523
|
*/
|
|
3471
|
-
get uint64le():
|
|
3524
|
+
get uint64le(): BigValue;
|
|
3472
3525
|
/**
|
|
3473
3526
|
* Read unsigned 64 bit integer.
|
|
3474
3527
|
*
|
|
3475
|
-
*
|
|
3528
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3529
|
+
*
|
|
3530
|
+
* @returns {BigValue}
|
|
3476
3531
|
*/
|
|
3477
|
-
get ubigintle():
|
|
3532
|
+
get ubigintle(): BigValue;
|
|
3478
3533
|
/**
|
|
3479
3534
|
* Read unsigned 64 bit integer.
|
|
3480
3535
|
*
|
|
3481
|
-
*
|
|
3536
|
+
* Note: If ``enforceBigInt`` was set to ``true``, this always returns a ``BigInt`` otherwise it will return a ``number`` if integer safe.
|
|
3537
|
+
*
|
|
3538
|
+
* @returns {BigValue}
|
|
3482
3539
|
*/
|
|
3483
|
-
get uquadle():
|
|
3540
|
+
get uquadle(): BigValue;
|
|
3484
3541
|
/**
|
|
3485
3542
|
* Read double float.
|
|
3486
3543
|
*
|
|
@@ -3797,6 +3854,7 @@ declare class BiReader extends BiBase {
|
|
|
3797
3854
|
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
3798
3855
|
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
3799
3856
|
* @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
|
|
3857
|
+
* @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
|
|
3800
3858
|
*
|
|
3801
3859
|
* @since 2.0
|
|
3802
3860
|
*/
|
|
@@ -3811,6 +3869,7 @@ declare class BiWriter extends BiBase {
|
|
|
3811
3869
|
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
3812
3870
|
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
3813
3871
|
* @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
|
|
3872
|
+
* @param {BiOptions["enforceBigInt"]?} options.enforceBigInt - 64 bit value reads will always stay ``BigInt``.
|
|
3814
3873
|
*/
|
|
3815
3874
|
constructor(data?: Buffer | Uint8Array, options?: BiOptions);
|
|
3816
3875
|
/**
|