bireader 1.0.18 → 1.0.20
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 +25 -23
- package/lib/cjs/src/common.js +133 -35
- package/lib/cjs/src/common.js.map +1 -1
- package/lib/cjs/src/reader.js +119 -47
- package/lib/cjs/src/reader.js.map +1 -1
- package/lib/cjs/src/writer.js +119 -47
- package/lib/cjs/src/writer.js.map +1 -1
- package/lib/cjs/types/src/common.d.ts +5 -5
- package/lib/cjs/types/src/common.d.ts.map +1 -1
- package/lib/cjs/types/src/reader.d.ts +25 -21
- package/lib/cjs/types/src/reader.d.ts.map +1 -1
- package/lib/cjs/types/src/writer.d.ts +25 -21
- package/lib/cjs/types/src/writer.d.ts.map +1 -1
- package/lib/esm/src/common.js +133 -35
- package/lib/esm/src/common.js.map +1 -1
- package/lib/esm/src/reader.js +119 -47
- package/lib/esm/src/reader.js.map +1 -1
- package/lib/esm/src/writer.js +119 -47
- package/lib/esm/src/writer.js.map +1 -1
- package/lib/esm/types/src/common.d.ts +5 -5
- package/lib/esm/types/src/common.d.ts.map +1 -1
- package/lib/esm/types/src/reader.d.ts +25 -21
- package/lib/esm/types/src/reader.d.ts.map +1 -1
- package/lib/esm/types/src/writer.d.ts +25 -21
- package/lib/esm/types/src/writer.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -420,12 +420,14 @@ Common functions for setup, movement, manipulation and math shared by both.
|
|
|
420
420
|
<tr>
|
|
421
421
|
<td>Name</td>
|
|
422
422
|
<td>delete(startOffset, endOffset, consume)</td>
|
|
423
|
-
<td align="center"
|
|
424
|
-
<td
|
|
423
|
+
<td align="center">Start byte of data (default 0), end byte of data (default current byte position), move byte position to after data read (default false)</td>
|
|
424
|
+
<td >Removes and returns data. <br><b>Note:</b> Errors on strict mode</td>
|
|
425
425
|
</tr>
|
|
426
426
|
<tr>
|
|
427
|
-
<td>
|
|
428
|
-
<td>clip(
|
|
427
|
+
<td>Preset</td>
|
|
428
|
+
<td>clip()<br>trim()</td>
|
|
429
|
+
<td align="center">None</td>
|
|
430
|
+
<td >Removes data after the current byte position and returns data. <br><b>Note:</b> Errors on strict mode</td>
|
|
429
431
|
</tr>
|
|
430
432
|
<tr>
|
|
431
433
|
<td>Name</td>
|
|
@@ -507,7 +509,7 @@ Common functions for setup, movement, manipulation and math shared by both.
|
|
|
507
509
|
<tr>
|
|
508
510
|
<td>Name</td>
|
|
509
511
|
<td>xorThis(<b>xorKey</b>, length, consume)
|
|
510
|
-
<td align="center"><b>Byte value, string, Uint8Array or Buffer</b>, length of bytes starting at current byte (repeats when longer, default 1 byte for byte value, string length or end of data for string, array length or end of data for
|
|
512
|
+
<td align="center"><b>Byte value, string, Uint8Array or Buffer</b>, length of bytes starting at current byte (repeats when longer, default 1 byte for byte value, string length or end of data for string, array length or end of data for array or Buffer), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
511
513
|
<td>XOR data <b>Note:</b> Will loop if operation length is longer than supplied key.</td>
|
|
512
514
|
</tr>
|
|
513
515
|
<tr>
|
|
@@ -519,31 +521,31 @@ Common functions for setup, movement, manipulation and math shared by both.
|
|
|
519
521
|
<tr>
|
|
520
522
|
<td>Name</td>
|
|
521
523
|
<td>orThis(<b>orKey</b>, length, consume)
|
|
522
|
-
<td align="center"><b>Byte value, string, Uint8Array or Buffer</b>, length of bytes starting at current byte (repeats when longer, default 1 byte for byte value, string length or end of data for string, array length or end of data for
|
|
524
|
+
<td align="center"><b>Byte value, string, Uint8Array or Buffer</b>, length of bytes starting at current byte (repeats when longer, default 1 byte for byte value, string length or end of data for string, array length or end of data for array or Buffer), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
523
525
|
<td>OR data <b>Note:</b> Will loop if operation length is longer than supplied key.</td>
|
|
524
526
|
</tr>
|
|
525
527
|
<tr>
|
|
526
528
|
<td>Name</td>
|
|
527
529
|
<td>and(<b>andKey</b>, startOffset, endOffset, consume)
|
|
528
|
-
<td align="center"><b>Byte value, string,
|
|
530
|
+
<td align="center"><b>Byte value, string, number array or Buffer</b>, byte position to start (default current position), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
529
531
|
<td >AND data <b>Note:</b> Will loop if operation length is longer than supplied key.</td>
|
|
530
532
|
</tr>
|
|
531
533
|
<tr>
|
|
532
534
|
<td>Name</td>
|
|
533
535
|
<td>andThis(<b>andKey</b>, length, consume)
|
|
534
|
-
<td align="center"><b>Byte value, string,
|
|
536
|
+
<td align="center"><b>Byte value, string, number array or Buffer</b>, length of bytes starting at current byte (repeats when longer, default 1 byte for byte value, string length or end of data for string, array length or end of data for array or Buffer), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
535
537
|
<td>AND data <b>Note:</b> Will loop if operation length is longer than supplied key.</td>
|
|
536
538
|
</tr>
|
|
537
539
|
<tr>
|
|
538
540
|
<td>Name</td>
|
|
539
|
-
<td>add(<b>
|
|
540
|
-
<td align="center"><b>
|
|
541
|
-
<td >Add value to data (per byte)
|
|
541
|
+
<td>add(<b>addKey</b>, startOffset, endOffset, consume)
|
|
542
|
+
<td align="center"><b>Byte value, string, number array or Buffer</b>, byte position to start (default current position), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
543
|
+
<td >Add value to data (per byte). <b>Note:</b> Will loop if operation length is longer than supplied key.</td>
|
|
542
544
|
</tr>
|
|
543
545
|
<tr>
|
|
544
546
|
<td>Name</td>
|
|
545
|
-
<td>addThis(<b>
|
|
546
|
-
<td align="center"><b>
|
|
547
|
+
<td>addThis(<b>addKey</b>, length, consume)
|
|
548
|
+
<td align="center"><b>Byte value, string, number array or Buffer</b>, length of bytes starting at current byte (repeats when longer, default 1 byte for byte value, string length or end of data for string, array length or end of data for array or Buffer), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
547
549
|
<td>Add value to data (per byte)</td>
|
|
548
550
|
</tr>
|
|
549
551
|
<tr>
|
|
@@ -560,26 +562,26 @@ Common functions for setup, movement, manipulation and math shared by both.
|
|
|
560
562
|
</tr>
|
|
561
563
|
<tr>
|
|
562
564
|
<td>Name</td>
|
|
563
|
-
<td>lShift(<b>
|
|
564
|
-
<td align="center"><b>
|
|
565
|
-
<td >Left shift data (per byte)
|
|
565
|
+
<td>lShift(<b>shiftKey</b>, startOffset, endOffset, consume)
|
|
566
|
+
<td align="center"><b>Byte value, string, number array or Buffer</b>, byte position to start (default current position), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
567
|
+
<td >Left shift data (per byte). <b>Note:</b> Will loop if operation length is longer than supplied key.</td>
|
|
566
568
|
</tr>
|
|
567
569
|
<tr>
|
|
568
570
|
<td>Name</td>
|
|
569
|
-
<td>lShiftThis(<b>
|
|
570
|
-
<td align="center"><b>
|
|
571
|
+
<td>lShiftThis(<b>shiftKey</b>, length, consume)
|
|
572
|
+
<td align="center"><b>Byte value, string, number array or Buffer</b>, length of bytes starting at current byte (repeats when longer, default 1 byte for byte value, string length or end of data for string, array length or end of data for array or Buffer), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
571
573
|
<td>Left shift data (per byte)</td>
|
|
572
574
|
</tr>
|
|
573
575
|
<tr>
|
|
574
576
|
<td>Name</td>
|
|
575
|
-
<td>rShift(<b>
|
|
576
|
-
<td align="center"><b>
|
|
577
|
-
<td >Right shift data (per byte)
|
|
577
|
+
<td>rShift(<b>shiftKey</b>, startOffset, endOffset, consume)
|
|
578
|
+
<td align="center"><b>Byte value, string, number array or Buffer</b>, byte position to start (default current position), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
579
|
+
<td >Right shift data (per byte). <b>Note:</b> Will loop if operation length is longer than supplied key.</td>
|
|
578
580
|
</tr>
|
|
579
581
|
<tr>
|
|
580
582
|
<td>Name</td>
|
|
581
|
-
<td>rShiftThis(<b>
|
|
582
|
-
<td align="center"><b>
|
|
583
|
+
<td>rShiftThis(<b>shiftKey</b>, length, consume)
|
|
584
|
+
<td align="center"><b>Byte value, string, number array or Buffer</b>, length of bytes starting at current byte (repeats when longer, default 1 byte for byte value, string length or end of data for string, array length or end of data for array or Buffer), byte position to end (default end of data), move byte position to after operation (default false)</td>
|
|
583
585
|
<td>Right shift data (per byte)</td>
|
|
584
586
|
</tr>
|
|
585
587
|
</tbody>
|
package/lib/cjs/src/common.js
CHANGED
|
@@ -112,9 +112,11 @@ function remove(_this, startOffset, endOffset, consume, remove, fillValue) {
|
|
|
112
112
|
if (consume == true) {
|
|
113
113
|
if (remove != true) {
|
|
114
114
|
_this.offset = new_offset;
|
|
115
|
+
_this.bitoffset = 0;
|
|
115
116
|
}
|
|
116
117
|
else {
|
|
117
118
|
_this.offset = new_start;
|
|
119
|
+
_this.bitoffset = 0;
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
return data_removed;
|
|
@@ -170,6 +172,7 @@ function addData(_this, data, consume, offset, repalce) {
|
|
|
170
172
|
}
|
|
171
173
|
if (consume) {
|
|
172
174
|
_this.offset = needed_size;
|
|
175
|
+
_this.bitoffset = 0;
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
exports.addData = addData;
|
|
@@ -356,7 +359,7 @@ function hexDump(_this, options) {
|
|
|
356
359
|
console.log(rows.join("\n"));
|
|
357
360
|
}
|
|
358
361
|
exports.hexDump = hexDump;
|
|
359
|
-
function AND(_this,
|
|
362
|
+
function AND(_this, and_key, start, end, consume) {
|
|
360
363
|
const input = _this.data;
|
|
361
364
|
if ((end || 0) > _this.size) {
|
|
362
365
|
if (_this.strict == false) {
|
|
@@ -367,27 +370,29 @@ function AND(_this, xor_key, start, end, consume) {
|
|
|
367
370
|
throw new Error("\x1b[33m[Strict mode]\x1b[0m: End offset outside of data: endOffset" + (end || 0) + " of " + _this.size);
|
|
368
371
|
}
|
|
369
372
|
}
|
|
370
|
-
if (typeof
|
|
373
|
+
if (typeof and_key == "number") {
|
|
371
374
|
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
372
|
-
input[i] = input[i] & (
|
|
375
|
+
input[i] = input[i] & (and_key & 0xff);
|
|
373
376
|
if (consume) {
|
|
374
377
|
_this.offset = i;
|
|
378
|
+
_this.bitoffset = 0;
|
|
375
379
|
}
|
|
376
380
|
}
|
|
377
381
|
}
|
|
378
382
|
else {
|
|
379
|
-
if (_this.isBufferOrUint8Array(
|
|
383
|
+
if (_this.isBufferOrUint8Array(and_key)) {
|
|
380
384
|
let number = -1;
|
|
381
385
|
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
382
|
-
if (number !=
|
|
386
|
+
if (number != and_key.length - 1) {
|
|
383
387
|
number = number + 1;
|
|
384
388
|
}
|
|
385
389
|
else {
|
|
386
390
|
number = 0;
|
|
387
391
|
}
|
|
388
|
-
input[i] = input[i] &
|
|
392
|
+
input[i] = input[i] & and_key[number];
|
|
389
393
|
if (consume) {
|
|
390
394
|
_this.offset = i;
|
|
395
|
+
_this.bitoffset = 0;
|
|
391
396
|
}
|
|
392
397
|
}
|
|
393
398
|
}
|
|
@@ -397,7 +402,7 @@ function AND(_this, xor_key, start, end, consume) {
|
|
|
397
402
|
}
|
|
398
403
|
}
|
|
399
404
|
exports.AND = AND;
|
|
400
|
-
function OR(_this,
|
|
405
|
+
function OR(_this, or_key, start, end, consume) {
|
|
401
406
|
const input = _this.data;
|
|
402
407
|
if ((end || 0) > _this.size) {
|
|
403
408
|
if (_this.strict == false) {
|
|
@@ -408,27 +413,29 @@ function OR(_this, xor_key, start, end, consume) {
|
|
|
408
413
|
throw new Error("\x1b[33m[Strict mode]\x1b[0m: End offset outside of data: endOffset" + (end || 0) + " of " + _this.size);
|
|
409
414
|
}
|
|
410
415
|
}
|
|
411
|
-
if (typeof
|
|
416
|
+
if (typeof or_key == "number") {
|
|
412
417
|
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
413
|
-
input[i] = input[i] | (
|
|
418
|
+
input[i] = input[i] | (or_key & 0xff);
|
|
414
419
|
if (consume) {
|
|
415
420
|
_this.offset = i;
|
|
421
|
+
_this.bitoffset = 0;
|
|
416
422
|
}
|
|
417
423
|
}
|
|
418
424
|
}
|
|
419
425
|
else {
|
|
420
|
-
if (_this.isBufferOrUint8Array(
|
|
426
|
+
if (_this.isBufferOrUint8Array(or_key)) {
|
|
421
427
|
let number = -1;
|
|
422
428
|
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
423
|
-
if (number !=
|
|
429
|
+
if (number != or_key.length - 1) {
|
|
424
430
|
number = number + 1;
|
|
425
431
|
}
|
|
426
432
|
else {
|
|
427
433
|
number = 0;
|
|
428
434
|
}
|
|
429
|
-
input[i] = input[i] |
|
|
435
|
+
input[i] = input[i] | or_key[number];
|
|
430
436
|
if (consume) {
|
|
431
437
|
_this.offset = i;
|
|
438
|
+
_this.bitoffset = 0;
|
|
432
439
|
}
|
|
433
440
|
}
|
|
434
441
|
}
|
|
@@ -454,6 +461,7 @@ function XOR(_this, xor_key, start, end, consume) {
|
|
|
454
461
|
input[i] = input[i] ^ (xor_key & 0xff);
|
|
455
462
|
if (consume) {
|
|
456
463
|
_this.offset = i;
|
|
464
|
+
_this.bitoffset = 0;
|
|
457
465
|
}
|
|
458
466
|
}
|
|
459
467
|
}
|
|
@@ -470,6 +478,7 @@ function XOR(_this, xor_key, start, end, consume) {
|
|
|
470
478
|
input[i] = input[i] ^ xor_key[number];
|
|
471
479
|
if (consume) {
|
|
472
480
|
_this.offset = i;
|
|
481
|
+
_this.bitoffset = 0;
|
|
473
482
|
}
|
|
474
483
|
}
|
|
475
484
|
}
|
|
@@ -493,11 +502,13 @@ function NOT(_this, start, end, consume) {
|
|
|
493
502
|
_this.data[i] = ~_this.data[i];
|
|
494
503
|
if (consume) {
|
|
495
504
|
_this.offset = i;
|
|
505
|
+
_this.bitoffset = 0;
|
|
496
506
|
}
|
|
497
507
|
}
|
|
498
508
|
}
|
|
499
509
|
exports.NOT = NOT;
|
|
500
|
-
function LSHIFT(_this,
|
|
510
|
+
function LSHIFT(_this, shift_key, start, end, consume) {
|
|
511
|
+
const input = _this.data;
|
|
501
512
|
if ((end || 0) > _this.size) {
|
|
502
513
|
if (_this.strict == false) {
|
|
503
514
|
_this.extendArray((end || 0) - _this.size);
|
|
@@ -507,15 +518,40 @@ function LSHIFT(_this, value, start, end, consume) {
|
|
|
507
518
|
throw new Error("\x1b[33m[Strict mode]\x1b[0m: End offset outside of data: endOffset" + (end || 0) + " of " + _this.size);
|
|
508
519
|
}
|
|
509
520
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
521
|
+
if (typeof shift_key == "number") {
|
|
522
|
+
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
523
|
+
input[i] = input[i] << shift_key;
|
|
524
|
+
if (consume) {
|
|
525
|
+
_this.offset = i;
|
|
526
|
+
_this.bitoffset = 0;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
if (_this.isBufferOrUint8Array(shift_key)) {
|
|
532
|
+
let number = -1;
|
|
533
|
+
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
534
|
+
if (number != shift_key.length - 1) {
|
|
535
|
+
number = number + 1;
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
number = 0;
|
|
539
|
+
}
|
|
540
|
+
input[i] = input[i] << shift_key[number];
|
|
541
|
+
if (consume) {
|
|
542
|
+
_this.offset = i;
|
|
543
|
+
_this.bitoffset = 0;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
throw new Error("XOR key must be a byte value, string, Uint8Array or Buffer");
|
|
514
549
|
}
|
|
515
550
|
}
|
|
516
551
|
}
|
|
517
552
|
exports.LSHIFT = LSHIFT;
|
|
518
|
-
function RSHIFT(_this,
|
|
553
|
+
function RSHIFT(_this, shift_key, start, end, consume) {
|
|
554
|
+
const input = _this.data;
|
|
519
555
|
if ((end || 0) > _this.size) {
|
|
520
556
|
if (_this.strict == false) {
|
|
521
557
|
_this.extendArray((end || 0) - _this.size);
|
|
@@ -525,15 +561,40 @@ function RSHIFT(_this, value, start, end, consume) {
|
|
|
525
561
|
throw new Error("\x1b[33m[Strict mode]\x1b[0m: End offset outside of data: endOffset" + (end || 0) + " of " + _this.size);
|
|
526
562
|
}
|
|
527
563
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
564
|
+
if (typeof shift_key == "number") {
|
|
565
|
+
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
566
|
+
input[i] = input[i] >> shift_key;
|
|
567
|
+
if (consume) {
|
|
568
|
+
_this.offset = i;
|
|
569
|
+
_this.bitoffset = 0;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
if (_this.isBufferOrUint8Array(shift_key)) {
|
|
575
|
+
let number = -1;
|
|
576
|
+
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
577
|
+
if (number != shift_key.length - 1) {
|
|
578
|
+
number = number + 1;
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
number = 0;
|
|
582
|
+
}
|
|
583
|
+
input[i] = input[i] >> shift_key[number];
|
|
584
|
+
if (consume) {
|
|
585
|
+
_this.offset = i;
|
|
586
|
+
_this.bitoffset = 0;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
throw new Error("XOR key must be a byte value, string, Uint8Array or Buffer");
|
|
532
592
|
}
|
|
533
593
|
}
|
|
534
594
|
}
|
|
535
595
|
exports.RSHIFT = RSHIFT;
|
|
536
|
-
function ADD(_this,
|
|
596
|
+
function ADD(_this, add_key, start, end, consume) {
|
|
597
|
+
const input = _this.data;
|
|
537
598
|
if ((end || 0) > _this.size) {
|
|
538
599
|
if (_this.strict == false) {
|
|
539
600
|
_this.extendArray((end || 0) - _this.size);
|
|
@@ -543,10 +604,34 @@ function ADD(_this, value, start, end, consume) {
|
|
|
543
604
|
throw new Error("\x1b[33m[Strict mode]\x1b[0m: End offset outside of data: endOffset" + (end || 0) + " of " + _this.size);
|
|
544
605
|
}
|
|
545
606
|
}
|
|
546
|
-
|
|
547
|
-
_this.
|
|
548
|
-
|
|
549
|
-
|
|
607
|
+
if (typeof add_key == "number") {
|
|
608
|
+
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
609
|
+
input[i] = input[i] + add_key;
|
|
610
|
+
if (consume) {
|
|
611
|
+
_this.offset = i;
|
|
612
|
+
_this.bitoffset = 0;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
if (_this.isBufferOrUint8Array(add_key)) {
|
|
618
|
+
let number = -1;
|
|
619
|
+
for (let i = (start || 0); i < Math.min(end || _this.size, _this.size); i++) {
|
|
620
|
+
if (number != add_key.length - 1) {
|
|
621
|
+
number = number + 1;
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
number = 0;
|
|
625
|
+
}
|
|
626
|
+
input[i] = input[i] + add_key[number];
|
|
627
|
+
if (consume) {
|
|
628
|
+
_this.offset = i;
|
|
629
|
+
_this.bitoffset = 0;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
throw new Error("XOR key must be a byte value, string, Uint8Array or Buffer");
|
|
550
635
|
}
|
|
551
636
|
}
|
|
552
637
|
}
|
|
@@ -675,12 +760,14 @@ function wbyte(_this, value, unsigned) {
|
|
|
675
760
|
}
|
|
676
761
|
_this.data[_this.offset] = (unsigned == undefined || unsigned == false) ? value : value & 0xFF;
|
|
677
762
|
_this.offset += 1;
|
|
763
|
+
_this.bitoffset = 0;
|
|
678
764
|
}
|
|
679
765
|
exports.wbyte = wbyte;
|
|
680
766
|
function rbyte(_this, unsigned) {
|
|
681
767
|
_this.check_size(1);
|
|
682
768
|
var read = _this.data[_this.offset];
|
|
683
769
|
_this.offset += 1;
|
|
770
|
+
_this.bitoffset = 0;
|
|
684
771
|
if (unsigned == true) {
|
|
685
772
|
return read & 0xFF;
|
|
686
773
|
}
|
|
@@ -714,6 +801,7 @@ function wint16(_this, value, unsigned, endian) {
|
|
|
714
801
|
_this.data[_this.offset + 1] = (unsigned == undefined || unsigned == false) ? value : value & 0xff;
|
|
715
802
|
}
|
|
716
803
|
_this.offset += 2;
|
|
804
|
+
_this.bitoffset = 0;
|
|
717
805
|
}
|
|
718
806
|
exports.wint16 = wint16;
|
|
719
807
|
function rint16(_this, unsigned, endian) {
|
|
@@ -726,6 +814,7 @@ function rint16(_this, unsigned, endian) {
|
|
|
726
814
|
read = (_this.data[_this.offset] << 8) | _this.data[_this.offset + 1];
|
|
727
815
|
}
|
|
728
816
|
_this.offset += 2;
|
|
817
|
+
_this.bitoffset = 0;
|
|
729
818
|
if (unsigned == undefined || unsigned == false) {
|
|
730
819
|
return read & 0x8000 ? -(0x10000 - read) : read;
|
|
731
820
|
}
|
|
@@ -762,6 +851,8 @@ function rhalffloat(_this, endian) {
|
|
|
762
851
|
// Normalized number
|
|
763
852
|
floatValue = (sign === 0 ? 1 : -1) * Math.pow(2, exponent - 15) * (1 + fraction / 0x0400);
|
|
764
853
|
}
|
|
854
|
+
_this.offset += 2;
|
|
855
|
+
_this.bitoffset = 0;
|
|
765
856
|
return floatValue;
|
|
766
857
|
}
|
|
767
858
|
exports.rhalffloat = rhalffloat;
|
|
@@ -806,6 +897,7 @@ function whalffloat(_this, value, endian) {
|
|
|
806
897
|
_this.data[_this.offset + 1] = halfFloatBits & 0xFF;
|
|
807
898
|
}
|
|
808
899
|
_this.offset += 2;
|
|
900
|
+
_this.bitoffset = 0;
|
|
809
901
|
}
|
|
810
902
|
exports.whalffloat = whalffloat;
|
|
811
903
|
function wint32(_this, value, unsigned, endian) {
|
|
@@ -837,6 +929,7 @@ function wint32(_this, value, unsigned, endian) {
|
|
|
837
929
|
_this.data[_this.offset + 3] = (unsigned == undefined || unsigned == false) ? value : value & 0xFF;
|
|
838
930
|
}
|
|
839
931
|
_this.offset += 4;
|
|
932
|
+
_this.bitoffset = 0;
|
|
840
933
|
}
|
|
841
934
|
exports.wint32 = wint32;
|
|
842
935
|
function rint32(_this, unsigned, endian) {
|
|
@@ -849,6 +942,7 @@ function rint32(_this, unsigned, endian) {
|
|
|
849
942
|
read = (_this.data[_this.offset] << 24) | (_this.data[_this.offset + 1] << 16) | (_this.data[_this.offset + 2] << 8) | _this.data[_this.offset + 3];
|
|
850
943
|
}
|
|
851
944
|
_this.offset += 4;
|
|
945
|
+
_this.bitoffset = 0;
|
|
852
946
|
if (unsigned == undefined || unsigned == false) {
|
|
853
947
|
return read;
|
|
854
948
|
}
|
|
@@ -879,6 +973,8 @@ function rfloat(_this, endian) {
|
|
|
879
973
|
// Normalized number
|
|
880
974
|
floatValue = Math.pow(-1, isNegative) * Math.pow(2, exponent - 127) * (1 + fraction / Math.pow(2, 23));
|
|
881
975
|
}
|
|
976
|
+
_this.offset += 4;
|
|
977
|
+
_this.bitoffset = 0;
|
|
882
978
|
return floatValue;
|
|
883
979
|
}
|
|
884
980
|
exports.rfloat = rfloat;
|
|
@@ -902,6 +998,7 @@ function wfloat(_this, value, endian) {
|
|
|
902
998
|
shift += 8;
|
|
903
999
|
}
|
|
904
1000
|
_this.offset += 4;
|
|
1001
|
+
_this.bitoffset = 0;
|
|
905
1002
|
}
|
|
906
1003
|
exports.wfloat = wfloat;
|
|
907
1004
|
function rint64(_this, unsigned, endian) {
|
|
@@ -917,10 +1014,6 @@ function rint64(_this, unsigned, endian) {
|
|
|
917
1014
|
if (value & (BigInt(1) << BigInt(63))) {
|
|
918
1015
|
value -= BigInt(1) << BigInt(64);
|
|
919
1016
|
}
|
|
920
|
-
return value;
|
|
921
|
-
}
|
|
922
|
-
else {
|
|
923
|
-
return value;
|
|
924
1017
|
}
|
|
925
1018
|
}
|
|
926
1019
|
else {
|
|
@@ -932,12 +1025,11 @@ function rint64(_this, unsigned, endian) {
|
|
|
932
1025
|
if (value & (BigInt(1) << BigInt(63))) {
|
|
933
1026
|
value -= BigInt(1) << BigInt(64);
|
|
934
1027
|
}
|
|
935
|
-
return value;
|
|
936
|
-
}
|
|
937
|
-
else {
|
|
938
|
-
return value;
|
|
939
1028
|
}
|
|
940
1029
|
}
|
|
1030
|
+
_this.offset += 8;
|
|
1031
|
+
_this.bitoffset = 0;
|
|
1032
|
+
return value;
|
|
941
1033
|
}
|
|
942
1034
|
exports.rint64 = rint64;
|
|
943
1035
|
function wint64(_this, value, unsigned, endian) {
|
|
@@ -992,6 +1084,7 @@ function wint64(_this, value, unsigned, endian) {
|
|
|
992
1084
|
}
|
|
993
1085
|
}
|
|
994
1086
|
_this.offset += 8;
|
|
1087
|
+
_this.bitoffset = 0;
|
|
995
1088
|
}
|
|
996
1089
|
exports.wint64 = wint64;
|
|
997
1090
|
function wdfloat(_this, value, endian) {
|
|
@@ -1015,6 +1108,7 @@ function wdfloat(_this, value, endian) {
|
|
|
1015
1108
|
}
|
|
1016
1109
|
}
|
|
1017
1110
|
_this.offset += 8;
|
|
1111
|
+
_this.bitoffset = 0;
|
|
1018
1112
|
}
|
|
1019
1113
|
exports.wdfloat = wdfloat;
|
|
1020
1114
|
function rdfloat(_this, endian) {
|
|
@@ -1045,6 +1139,8 @@ function rdfloat(_this, endian) {
|
|
|
1045
1139
|
// Normalized number
|
|
1046
1140
|
floatValue = (sign == 0n ? 1 : -1) * Math.pow(2, exponent) * (1 + fraction);
|
|
1047
1141
|
}
|
|
1142
|
+
_this.offset += 8;
|
|
1143
|
+
_this.bitoffset = 0;
|
|
1048
1144
|
return floatValue;
|
|
1049
1145
|
}
|
|
1050
1146
|
exports.rdfloat = rdfloat;
|
|
@@ -1225,6 +1321,7 @@ function wstring(_this, string, options) {
|
|
|
1225
1321
|
}
|
|
1226
1322
|
}
|
|
1227
1323
|
_this.offset += totalLength;
|
|
1324
|
+
_this.bitoffset = 0;
|
|
1228
1325
|
}
|
|
1229
1326
|
else if (stringType == 'pascal' || stringType == 'wide-pascal') {
|
|
1230
1327
|
if (encoding == undefined) {
|
|
@@ -1290,6 +1387,7 @@ function wstring(_this, string, options) {
|
|
|
1290
1387
|
}
|
|
1291
1388
|
}
|
|
1292
1389
|
_this.offset += totalLength;
|
|
1390
|
+
_this.bitoffset = 0;
|
|
1293
1391
|
}
|
|
1294
1392
|
else {
|
|
1295
1393
|
throw new Error('Unsupported string type: ' + stringType);
|