bireader 3.1.6 → 3.1.8
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.browser.d.ts +30 -4
- package/dist/index.browser.js +32 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.d.ts +62 -8
- package/dist/index.cjs.js +67 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +62 -8
- package/dist/index.esm.d.ts +62 -8
- package/dist/index.esm.js +67 -13
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.d.ts
CHANGED
|
@@ -7478,7 +7478,6 @@ interface BinaryAliasReaderStreamer extends BiBaseStreamer {
|
|
|
7478
7478
|
wpstring4le(stripNull?: stringOptions["stripNull"]): string;
|
|
7479
7479
|
}
|
|
7480
7480
|
|
|
7481
|
-
declare const BiReaderBase: typeof BiBase;
|
|
7482
7481
|
/**
|
|
7483
7482
|
* Binary reader, includes bitfields and strings.
|
|
7484
7483
|
*
|
|
@@ -7492,7 +7491,7 @@ declare const BiReaderBase: typeof BiBase;
|
|
|
7492
7491
|
*
|
|
7493
7492
|
* @since 2.0
|
|
7494
7493
|
*/
|
|
7495
|
-
declare class
|
|
7494
|
+
declare class BiRead extends BiBase implements BinaryAliasReader {
|
|
7496
7495
|
/**
|
|
7497
7496
|
* Binary reader, includes bitfields and strings.
|
|
7498
7497
|
*
|
|
@@ -7812,6 +7811,20 @@ declare class BiReader extends BiReaderBase implements BinaryAliasReader {
|
|
|
7812
7811
|
wpstring4be(stripNull?: stringOptions["stripNull"]): string;
|
|
7813
7812
|
wpstring4le(stripNull?: stringOptions["stripNull"]): string;
|
|
7814
7813
|
}
|
|
7814
|
+
/**
|
|
7815
|
+
* Binary reader, includes bitfields and strings.
|
|
7816
|
+
*
|
|
7817
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
|
|
7818
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
7819
|
+
* @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
|
|
7820
|
+
* @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
|
|
7821
|
+
* @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
7822
|
+
* @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
|
|
7823
|
+
* @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
|
|
7824
|
+
*
|
|
7825
|
+
* @since 2.0
|
|
7826
|
+
*/
|
|
7827
|
+
declare const BiReader: typeof BiRead;
|
|
7815
7828
|
|
|
7816
7829
|
interface BinaryAliasWriter extends BiBase {
|
|
7817
7830
|
/**
|
|
@@ -12458,7 +12471,6 @@ interface BinaryAliasWriterStreamer extends BiBaseStreamer {
|
|
|
12458
12471
|
wpstring4be(string: string): void;
|
|
12459
12472
|
}
|
|
12460
12473
|
|
|
12461
|
-
declare const BiWriterBase: typeof BiBase;
|
|
12462
12474
|
/**
|
|
12463
12475
|
* Binary writer, includes bitfields and strings.
|
|
12464
12476
|
*
|
|
@@ -12472,7 +12484,7 @@ declare const BiWriterBase: typeof BiBase;
|
|
|
12472
12484
|
*
|
|
12473
12485
|
* @since 2.0
|
|
12474
12486
|
*/
|
|
12475
|
-
declare class
|
|
12487
|
+
declare class BiWrite extends BiBase implements BinaryAliasWriter {
|
|
12476
12488
|
/**
|
|
12477
12489
|
* Binary writer, includes bitfields and strings.
|
|
12478
12490
|
*
|
|
@@ -12797,8 +12809,21 @@ declare class BiWriter extends BiWriterBase implements BinaryAliasWriter {
|
|
|
12797
12809
|
wpstring4le(string: string): void;
|
|
12798
12810
|
wpstring4be(string: string): void;
|
|
12799
12811
|
}
|
|
12812
|
+
/**
|
|
12813
|
+
* Binary writer, includes bitfields and strings.
|
|
12814
|
+
*
|
|
12815
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
|
|
12816
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
12817
|
+
* @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
|
|
12818
|
+
* @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
|
|
12819
|
+
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
12820
|
+
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
12821
|
+
* @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``.
|
|
12822
|
+
*
|
|
12823
|
+
* @since 2.0
|
|
12824
|
+
*/
|
|
12825
|
+
declare const BiWriter: typeof BiWrite;
|
|
12800
12826
|
|
|
12801
|
-
declare const BiReaderStreamer: typeof BiBaseStreamer;
|
|
12802
12827
|
/**
|
|
12803
12828
|
* Binary reader, includes bitfields and strings.
|
|
12804
12829
|
*
|
|
@@ -12812,7 +12837,7 @@ declare const BiReaderStreamer: typeof BiBaseStreamer;
|
|
|
12812
12837
|
*
|
|
12813
12838
|
* @since 3.1
|
|
12814
12839
|
*/
|
|
12815
|
-
declare class
|
|
12840
|
+
declare class BiReaderStreamer extends BiBaseStreamer implements BinaryAliasReaderStreamer {
|
|
12816
12841
|
/**
|
|
12817
12842
|
* Binary reader, includes bitfields and strings.
|
|
12818
12843
|
*
|
|
@@ -13134,8 +13159,21 @@ declare class BiReaderStream extends BiReaderStreamer implements BinaryAliasRead
|
|
|
13134
13159
|
wpstring4be(stripNull?: stringOptions["stripNull"]): string;
|
|
13135
13160
|
wpstring4le(stripNull?: stringOptions["stripNull"]): string;
|
|
13136
13161
|
}
|
|
13162
|
+
/**
|
|
13163
|
+
* Binary reader, includes bitfields and strings.
|
|
13164
|
+
*
|
|
13165
|
+
* @param {string} filePath - Path to file
|
|
13166
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
13167
|
+
* @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
|
|
13168
|
+
* @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
|
|
13169
|
+
* @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
13170
|
+
* @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
|
|
13171
|
+
* @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
|
|
13172
|
+
*
|
|
13173
|
+
* @since 3.1
|
|
13174
|
+
*/
|
|
13175
|
+
declare const BiReaderStream: typeof BiReaderStreamer;
|
|
13137
13176
|
|
|
13138
|
-
declare const BiWriterStreamer: typeof BiBaseStreamer;
|
|
13139
13177
|
/**
|
|
13140
13178
|
* Binary writer, includes bitfields and strings.
|
|
13141
13179
|
*
|
|
@@ -13151,7 +13189,7 @@ declare const BiWriterStreamer: typeof BiBaseStreamer;
|
|
|
13151
13189
|
*
|
|
13152
13190
|
* @since 3.1
|
|
13153
13191
|
*/
|
|
13154
|
-
declare class
|
|
13192
|
+
declare class BiWriterStreamer extends BiBaseStreamer implements BinaryAliasWriterStreamer {
|
|
13155
13193
|
/**
|
|
13156
13194
|
* Binary writer, includes bitfields and strings.
|
|
13157
13195
|
*
|
|
@@ -13478,6 +13516,22 @@ declare class BiWriterStream extends BiWriterStreamer implements BinaryAliasWrit
|
|
|
13478
13516
|
wpstring4le(string: string): void;
|
|
13479
13517
|
wpstring4be(string: string): void;
|
|
13480
13518
|
}
|
|
13519
|
+
/**
|
|
13520
|
+
* Binary writer, includes bitfields and strings.
|
|
13521
|
+
*
|
|
13522
|
+
* Note: Must start with .open() before writing.
|
|
13523
|
+
*
|
|
13524
|
+
* @param {string} filePath - Path to file
|
|
13525
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
13526
|
+
* @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
|
|
13527
|
+
* @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
|
|
13528
|
+
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
13529
|
+
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
13530
|
+
* @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``.
|
|
13531
|
+
*
|
|
13532
|
+
* @since 3.1
|
|
13533
|
+
*/
|
|
13534
|
+
declare const BiWriterStream: typeof BiWriterStreamer;
|
|
13481
13535
|
|
|
13482
13536
|
/**
|
|
13483
13537
|
* Not in use anymore.
|
package/dist/index.cjs.js
CHANGED
|
@@ -87,7 +87,7 @@ function _hexDump(data, options = {}, start, end) {
|
|
|
87
87
|
var addr = "";
|
|
88
88
|
for (let i = start; i < end; i += 16) {
|
|
89
89
|
addr = i.toString(16).padStart(5, '0');
|
|
90
|
-
var row = data.
|
|
90
|
+
var row = data.subarray(i, i + 16) || [];
|
|
91
91
|
var hex = Array.from(row, (byte) => byte.toString(16).padStart(2, '0')).join(' ');
|
|
92
92
|
rows.push(`${addr} ${hex.padEnd(47)} `);
|
|
93
93
|
}
|
|
@@ -391,7 +391,7 @@ function remove$1(ctx, startOffset, endOffset, consume, remove, fillValue) {
|
|
|
391
391
|
ctx.errorDump ? console.log("[Error], hexdump:\n" + ctx.hexdump({ returnString: true })) : "";
|
|
392
392
|
throw new Error("\x1b[33m[Strict mode]\x1b[0m: Can not remove data in strict mode: endOffset " + endOffset + " of " + ctx.size);
|
|
393
393
|
}
|
|
394
|
-
const data_removed = ctx.data.
|
|
394
|
+
const data_removed = ctx.data.subarray(new_start, new_offset);
|
|
395
395
|
if (remove) {
|
|
396
396
|
const part1 = ctx.data.subarray(0, new_start);
|
|
397
397
|
const part2 = ctx.data.subarray(new_offset, ctx.size);
|
|
@@ -6613,7 +6613,6 @@ function applyBinaryAliasReader(Base) {
|
|
|
6613
6613
|
};
|
|
6614
6614
|
}
|
|
6615
6615
|
|
|
6616
|
-
const BiReaderBase = applyBinaryAliasReader(BiBase);
|
|
6617
6616
|
/**
|
|
6618
6617
|
* Binary reader, includes bitfields and strings.
|
|
6619
6618
|
*
|
|
@@ -6627,7 +6626,7 @@ const BiReaderBase = applyBinaryAliasReader(BiBase);
|
|
|
6627
6626
|
*
|
|
6628
6627
|
* @since 2.0
|
|
6629
6628
|
*/
|
|
6630
|
-
class
|
|
6629
|
+
class BiRead extends BiBase {
|
|
6631
6630
|
/**
|
|
6632
6631
|
* Binary reader, includes bitfields and strings.
|
|
6633
6632
|
*
|
|
@@ -7615,6 +7614,20 @@ class BiReader extends BiReaderBase {
|
|
|
7615
7614
|
throw new Error("Method not implemented.");
|
|
7616
7615
|
}
|
|
7617
7616
|
}
|
|
7617
|
+
/**
|
|
7618
|
+
* Binary reader, includes bitfields and strings.
|
|
7619
|
+
*
|
|
7620
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
|
|
7621
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
7622
|
+
* @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
|
|
7623
|
+
* @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
|
|
7624
|
+
* @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
7625
|
+
* @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
|
|
7626
|
+
* @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
|
|
7627
|
+
*
|
|
7628
|
+
* @since 2.0
|
|
7629
|
+
*/
|
|
7630
|
+
const BiReader = applyBinaryAliasReader(BiRead);
|
|
7618
7631
|
|
|
7619
7632
|
function applyBinaryAliasWriter(Base) {
|
|
7620
7633
|
return class extends Base {
|
|
@@ -10593,7 +10606,6 @@ function applyBinaryAliasWriter(Base) {
|
|
|
10593
10606
|
};
|
|
10594
10607
|
}
|
|
10595
10608
|
|
|
10596
|
-
const BiWriterBase = applyBinaryAliasWriter(BiBase);
|
|
10597
10609
|
/**
|
|
10598
10610
|
* Binary writer, includes bitfields and strings.
|
|
10599
10611
|
*
|
|
@@ -10607,7 +10619,7 @@ const BiWriterBase = applyBinaryAliasWriter(BiBase);
|
|
|
10607
10619
|
*
|
|
10608
10620
|
* @since 2.0
|
|
10609
10621
|
*/
|
|
10610
|
-
class
|
|
10622
|
+
class BiWrite extends BiBase {
|
|
10611
10623
|
/**
|
|
10612
10624
|
* Binary writer, includes bitfields and strings.
|
|
10613
10625
|
*
|
|
@@ -11615,6 +11627,20 @@ class BiWriter extends BiWriterBase {
|
|
|
11615
11627
|
throw new Error("Method not implemented.");
|
|
11616
11628
|
}
|
|
11617
11629
|
}
|
|
11630
|
+
/**
|
|
11631
|
+
* Binary writer, includes bitfields and strings.
|
|
11632
|
+
*
|
|
11633
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
|
|
11634
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
11635
|
+
* @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
|
|
11636
|
+
* @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
|
|
11637
|
+
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
11638
|
+
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
11639
|
+
* @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``.
|
|
11640
|
+
*
|
|
11641
|
+
* @since 2.0
|
|
11642
|
+
*/
|
|
11643
|
+
const BiWriter = applyBinaryAliasWriter(BiWrite);
|
|
11618
11644
|
|
|
11619
11645
|
function MAX_LENGTH() {
|
|
11620
11646
|
return buff__namespace.constants.MAX_LENGTH;
|
|
@@ -12489,7 +12515,7 @@ function fFloat(ctx, targetNumber, endian) {
|
|
|
12489
12515
|
return position + z; // Found the number, return the index
|
|
12490
12516
|
}
|
|
12491
12517
|
}
|
|
12492
|
-
position +=
|
|
12518
|
+
position += buffer.length;
|
|
12493
12519
|
}
|
|
12494
12520
|
return -1; // number not found
|
|
12495
12521
|
}
|
|
@@ -12528,7 +12554,7 @@ function fBigInt(ctx, targetNumber, unsigned, endian) {
|
|
|
12528
12554
|
}
|
|
12529
12555
|
// Update the last chunk for the next iteration
|
|
12530
12556
|
lastChunk = combinedBuffer.subarray(-8 + 1);
|
|
12531
|
-
ctx.offset +=
|
|
12557
|
+
ctx.offset += currentChunk.length;
|
|
12532
12558
|
}
|
|
12533
12559
|
return -1; // number not found
|
|
12534
12560
|
}
|
|
@@ -12582,7 +12608,7 @@ function fDoubleFloat(ctx, targetNumber, endian) {
|
|
|
12582
12608
|
return position + z; // Found the number, return the index
|
|
12583
12609
|
}
|
|
12584
12610
|
}
|
|
12585
|
-
position +=
|
|
12611
|
+
position += buffer.length;
|
|
12586
12612
|
}
|
|
12587
12613
|
return -1; // number not found
|
|
12588
12614
|
}
|
|
@@ -15445,7 +15471,6 @@ class BiBaseStreamer {
|
|
|
15445
15471
|
}
|
|
15446
15472
|
}
|
|
15447
15473
|
|
|
15448
|
-
const BiReaderStreamer = applyBinaryAliasReader(BiBaseStreamer);
|
|
15449
15474
|
/**
|
|
15450
15475
|
* Binary reader, includes bitfields and strings.
|
|
15451
15476
|
*
|
|
@@ -15459,7 +15484,7 @@ const BiReaderStreamer = applyBinaryAliasReader(BiBaseStreamer);
|
|
|
15459
15484
|
*
|
|
15460
15485
|
* @since 3.1
|
|
15461
15486
|
*/
|
|
15462
|
-
class
|
|
15487
|
+
class BiReaderStreamer extends BiBaseStreamer {
|
|
15463
15488
|
/**
|
|
15464
15489
|
* Binary reader, includes bitfields and strings.
|
|
15465
15490
|
*
|
|
@@ -16416,8 +16441,21 @@ class BiReaderStream extends BiReaderStreamer {
|
|
|
16416
16441
|
throw new Error("Method not implemented.");
|
|
16417
16442
|
}
|
|
16418
16443
|
}
|
|
16444
|
+
/**
|
|
16445
|
+
* Binary reader, includes bitfields and strings.
|
|
16446
|
+
*
|
|
16447
|
+
* @param {string} filePath - Path to file
|
|
16448
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
16449
|
+
* @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
|
|
16450
|
+
* @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
|
|
16451
|
+
* @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
16452
|
+
* @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
|
|
16453
|
+
* @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
|
|
16454
|
+
*
|
|
16455
|
+
* @since 3.1
|
|
16456
|
+
*/
|
|
16457
|
+
const BiReaderStream = applyBinaryAliasReader(BiReaderStreamer);
|
|
16419
16458
|
|
|
16420
|
-
const BiWriterStreamer = applyBinaryAliasWriter(BiBaseStreamer);
|
|
16421
16459
|
/**
|
|
16422
16460
|
* Binary writer, includes bitfields and strings.
|
|
16423
16461
|
*
|
|
@@ -16433,7 +16471,7 @@ const BiWriterStreamer = applyBinaryAliasWriter(BiBaseStreamer);
|
|
|
16433
16471
|
*
|
|
16434
16472
|
* @since 3.1
|
|
16435
16473
|
*/
|
|
16436
|
-
class
|
|
16474
|
+
class BiWriterStreamer extends BiBaseStreamer {
|
|
16437
16475
|
/**
|
|
16438
16476
|
* Binary writer, includes bitfields and strings.
|
|
16439
16477
|
*
|
|
@@ -17405,6 +17443,22 @@ class BiWriterStream extends BiWriterStreamer {
|
|
|
17405
17443
|
throw new Error("Method not implemented.");
|
|
17406
17444
|
}
|
|
17407
17445
|
}
|
|
17446
|
+
/**
|
|
17447
|
+
* Binary writer, includes bitfields and strings.
|
|
17448
|
+
*
|
|
17449
|
+
* Note: Must start with .open() before writing.
|
|
17450
|
+
*
|
|
17451
|
+
* @param {string} filePath - Path to file
|
|
17452
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
17453
|
+
* @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
|
|
17454
|
+
* @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
|
|
17455
|
+
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
17456
|
+
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
17457
|
+
* @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``.
|
|
17458
|
+
*
|
|
17459
|
+
* @since 3.1
|
|
17460
|
+
*/
|
|
17461
|
+
const BiWriterStream = applyBinaryAliasWriter(BiWriterStreamer);
|
|
17408
17462
|
|
|
17409
17463
|
/**
|
|
17410
17464
|
* Not in use anymore.
|