bireader 1.0.5 → 1.0.7

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.
@@ -0,0 +1,4062 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ *
5
+ * byte reader, includes bitfields and strings
6
+ *
7
+ * @param {Buffer|Uint8Array} data - ```Buffer``` or ```Uint8Array```
8
+ * @param {number} byteOffset - byte offset to start reader, default is 0
9
+ * @param {number} bitOffset - bit offset to start reader, 0-7
10
+ * @param {string} endianness - endianness ```big``` or ```little``` (default ```little```)
11
+ */
12
+ class bireader {
13
+ endian = "little";
14
+ offset = 0;
15
+ bitoffset = 0;
16
+ size = 0;
17
+ data;
18
+ check_size(read_size, read_bits) {
19
+ const new_off = this.offset + (read_size || 0) + Math.ceil((this.bitoffset + (read_bits || 0)) / 8);
20
+ if (new_off > this.size) {
21
+ throw new Error(`Reader reached end of data.`);
22
+ }
23
+ }
24
+ isBuffer(obj) {
25
+ return (typeof Buffer !== 'undefined' && obj instanceof Buffer);
26
+ }
27
+ isBufferOrUint8Array(obj) {
28
+ return obj instanceof Uint8Array || this.isBuffer(obj);
29
+ }
30
+ /**
31
+ *
32
+ * byte reader, includes bitfields and strings
33
+ *
34
+ * @param {Buffer|Uint8Array} data - ```Buffer``` or ```Uint8Array```
35
+ * @param {number} byteOffset - byte offset to start reader, default is 0
36
+ * @param {number} bitOffset - bit offset to start reader, 0-7
37
+ * @param {string} endianness - endianness ```big``` or ```little``` (default ```little```)
38
+ */
39
+ constructor(data, byteOffset, bitOffset, endianness) {
40
+ if (endianness != undefined && typeof endianness != "string") {
41
+ throw new Error("Endian must be big or little");
42
+ }
43
+ if (endianness != undefined && !(endianness == "big" || endianness == "little")) {
44
+ throw new Error("Byte order must be big or little");
45
+ }
46
+ this.endian = endianness || "little";
47
+ if (byteOffset != undefined) {
48
+ if (typeof byteOffset == "number") {
49
+ this.offset = Math.round(byteOffset) || 0;
50
+ }
51
+ else {
52
+ throw new Error("Byte offset must be number");
53
+ }
54
+ }
55
+ if (bitOffset != undefined) {
56
+ this.bitoffset = bitOffset % 8;
57
+ }
58
+ if (data == undefined) {
59
+ throw new Error("Data required");
60
+ }
61
+ else {
62
+ if (!this.isBufferOrUint8Array(data)) {
63
+ throw new Error("Write data must be Uint8Array or Buffer");
64
+ }
65
+ }
66
+ this.size = data.length + ((bitOffset || 0) % 8);
67
+ this.data = data;
68
+ }
69
+ /**
70
+ *
71
+ * Change endian, defaults to little
72
+ *
73
+ * Can be changed at any time, doesn't loose position
74
+ *
75
+ * @param {string} endian - endianness ```big``` or ```little```
76
+ */
77
+ endianness(endian) {
78
+ if (endian == undefined || typeof endian != "string") {
79
+ throw new Error("Endian must be big or little");
80
+ }
81
+ if (endian != undefined && !(endian == "big" || endian == "little")) {
82
+ throw new Error("Endian must be big or little");
83
+ }
84
+ this.endian = endian;
85
+ }
86
+ /**
87
+ *Sets endian to big
88
+ */
89
+ bigEndian() {
90
+ this.endianness("big");
91
+ }
92
+ /**
93
+ *Sets endian to big
94
+ */
95
+ big() {
96
+ this.endianness("big");
97
+ }
98
+ /**
99
+ *Sets endian to big
100
+ */
101
+ be() {
102
+ this.endianness("big");
103
+ }
104
+ /**
105
+ * Sets endian to little
106
+ */
107
+ littleEndian() {
108
+ this.endianness("little");
109
+ }
110
+ /**
111
+ * Sets endian to little
112
+ */
113
+ little() {
114
+ this.endianness("little");
115
+ }
116
+ /**
117
+ * Sets endian to little
118
+ */
119
+ le() {
120
+ this.endianness("little");
121
+ }
122
+ /**
123
+ * Move current read byte or bit position
124
+ *
125
+ * @param {number} bytes - bytes to skip
126
+ * @param {number} bits - bits to skip
127
+ */
128
+ skip(bytes, bits) {
129
+ this.check_size(bytes || 0);
130
+ if ((((bytes || 0) + this.offset) + Math.ceil((this.bitoffset + (bits || 0)) / 8)) > this.size) {
131
+ throw new Error("Seek outside of size of data: " + this.size);
132
+ }
133
+ this.bitoffset += (bits || 0) % 8;
134
+ this.offset += (bytes || 0);
135
+ }
136
+ /**
137
+ * Move current read byte or bit position
138
+ *
139
+ * @param {number} bytes - bytes to skip
140
+ * @param {number} bits - bits to skip
141
+ */
142
+ fskip(bytes, bits) {
143
+ this.skip(bytes, bits);
144
+ }
145
+ /**
146
+ * Change current byte or bit read position
147
+ *
148
+ * @param {number} byte - byte to jump to
149
+ * @param {number} bit - bit to jump to (0-7)
150
+ */
151
+ goto(byte, bit) {
152
+ if ((byte + Math.ceil((bit || 0) / 8)) > this.size) {
153
+ throw new Error("Goto outside of size of data: " + this.size);
154
+ }
155
+ this.offset = byte;
156
+ this.bitoffset = (bit || 0) % 8;
157
+ }
158
+ /**
159
+ * Change current byte or bit read position
160
+ *
161
+ * @param {number} byte - byte to jump to
162
+ * @param {number} bit - bit to jump to (0-7)
163
+ */
164
+ seek(byte, bit) {
165
+ this.goto(byte, bit);
166
+ }
167
+ /**
168
+ * Change current byte or bit read position
169
+ *
170
+ * @param {number} byte - byte to jump to
171
+ * @param {number} bit - bit to jump to (0-7)
172
+ */
173
+ fseek(byte, bit) {
174
+ this.goto(byte, bit);
175
+ }
176
+ /**
177
+ * Change current byte or bit read position
178
+ *
179
+ * @param {number} byte - byte to jump to
180
+ * @param {number} bit - bit to jump to (0-7)
181
+ */
182
+ jump(byte, bit) {
183
+ this.goto(byte, bit);
184
+ }
185
+ /**
186
+ * Change current byte or bit read position
187
+ *
188
+ * @param {number} byte - byte to jump to
189
+ * @param {number} bit - bit to jump to (0-7)
190
+ */
191
+ pointer(byte, bit) {
192
+ this.goto(byte, bit);
193
+ }
194
+ /**
195
+ * Change current byte or bit read position
196
+ *
197
+ * @param {number} byte - byte to jump to
198
+ * @param {number} bit - bit to jump to (0-7)
199
+ */
200
+ warp(byte, bit) {
201
+ this.goto(byte, bit);
202
+ }
203
+ /**
204
+ * Change current byte or bit read position
205
+ *
206
+ * @param {number} byte - byte to jump to
207
+ * @param {number} bit - bit to jump to (0-7)
208
+ */
209
+ fsetpos(byte, bit) {
210
+ this.goto(byte, bit);
211
+ }
212
+ /**
213
+ * Set offset to start of file
214
+ */
215
+ rewind() {
216
+ this.offset = 0;
217
+ this.bitoffset = 0;
218
+ }
219
+ /**
220
+ * Set offset to start of file
221
+ */
222
+ gotostart() {
223
+ this.offset = 0;
224
+ this.bitoffset = 0;
225
+ }
226
+ /**
227
+ * Set offset to start of file
228
+ */
229
+ tostart() {
230
+ this.offset = 0;
231
+ this.bitoffset = 0;
232
+ }
233
+ /**
234
+ * Get the current byte position
235
+ *
236
+ * @return {number} current byte position
237
+ */
238
+ ftell() {
239
+ return this.offset;
240
+ }
241
+ /**
242
+ * Get the current byte position
243
+ *
244
+ * @return {number} current byte position
245
+ */
246
+ tell() {
247
+ return this.offset;
248
+ }
249
+ /**
250
+ * Get the current byte position
251
+ *
252
+ * @return {number} current byte position
253
+ */
254
+ fgetpos() {
255
+ return this.offset;
256
+ }
257
+ /**
258
+ * Truncates array from start to current position unless supplied
259
+ * Note: Does not affect supplied data
260
+ * @param {number} startOffset - Start location, default 0
261
+ * @param {number} endOffset - end location, default current write position
262
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
263
+ */
264
+ clip(startOffset, endOffset) {
265
+ return this.data.slice(startOffset || 0, endOffset || this.offset);
266
+ }
267
+ /**
268
+ * Truncates array from start to current position unless supplied
269
+ * Note: Does not affect supplied data
270
+ * @param {number} startOffset - Start location, default 0
271
+ * @param {number} endOffset - end location, default current write position
272
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
273
+ */
274
+ crop(startOffset, endOffset) {
275
+ return this.data.slice(startOffset || 0, endOffset || this.offset);
276
+ }
277
+ /**
278
+ * Truncates array from start to current position unless supplied
279
+ * Note: Does not affect supplied data
280
+ * @param {number} startOffset - Start location, default 0
281
+ * @param {number} endOffset - end location, default current write position
282
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
283
+ */
284
+ truncate(startOffset, endOffset) {
285
+ return this.data.slice(startOffset || 0, endOffset || this.offset);
286
+ }
287
+ /**
288
+ * Truncates array from start to current position unless supplied
289
+ * Note: Does not affect supplied data
290
+ * @param {number} startOffset - Start location, default 0
291
+ * @param {number} endOffset - end location, default current write position
292
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
293
+ */
294
+ slice(startOffset, endOffset) {
295
+ return this.data.slice(startOffset || 0, endOffset || this.offset);
296
+ }
297
+ /**
298
+ * Extract array from current position to length supplied
299
+ * Note: Does not affect supplied data
300
+ * @param {number} length - length of data to copy from current offset
301
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
302
+ */
303
+ extract(length) {
304
+ if (this.offset + (length || 0) > this.size) {
305
+ throw new Error("End offset outside of data: " + this.size);
306
+ }
307
+ return this.data.slice(this.offset, this.offset + (length || 0));
308
+ }
309
+ /**
310
+ * Extract array from current position to length supplied
311
+ * Note: Does not affect supplied data
312
+ * @param {number} length - length of data to copy from current offset
313
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
314
+ */
315
+ wrap(length) {
316
+ if (this.offset + (length || 0) > this.size) {
317
+ throw new Error("End offset outside of data: " + this.size);
318
+ }
319
+ return this.data.slice(this.offset, this.offset + (length || 0));
320
+ }
321
+ /**
322
+ * Extract array from current position to length supplied
323
+ * Note: Does not affect supplied data
324
+ * @param {number} length - length of data to copy from current offset
325
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
326
+ */
327
+ lift(length) {
328
+ if (this.offset + (length || 0) > this.size) {
329
+ throw new Error("End offset outside of data: " + this.size);
330
+ }
331
+ return this.data.slice(this.offset, this.offset + (length || 0));
332
+ }
333
+ /**
334
+ * Returns current data
335
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
336
+ */
337
+ get() {
338
+ return this.data;
339
+ }
340
+ /**
341
+ * Returns current data
342
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
343
+ */
344
+ return() {
345
+ return this.data;
346
+ }
347
+ /**
348
+ * removes reading data
349
+ */
350
+ end() {
351
+ this.data = [];
352
+ }
353
+ /**
354
+ * removes reading data
355
+ */
356
+ close() {
357
+ this.data = [];
358
+ }
359
+ /**
360
+ * removes reading data
361
+ */
362
+ done() {
363
+ this.data = [];
364
+ }
365
+ /**
366
+ * removes reading data
367
+ */
368
+ finished() {
369
+ this.data = [];
370
+ }
371
+ //
372
+ //bit reader
373
+ //
374
+ /**
375
+ * Bit field reader
376
+ *
377
+ * Note: When returning to a byte read, remaining bits are dropped
378
+ *
379
+ * @param {number} bits - bits to read
380
+ * @param {boolean} unsigned - if the value is unsigned
381
+ * @param {string} endian - ``big`` or ``little`
382
+ * @returns number
383
+ */
384
+ readBit(bits, unsigned, endian) {
385
+ if (bits == undefined || typeof bits != "number") {
386
+ throw new Error("Enter number of bits to read");
387
+ }
388
+ if (bits <= 0 || bits > 32) {
389
+ throw new Error('Bit length must be between 1 and 32.');
390
+ }
391
+ const size_needed = ((((bits - 1) + this.bitoffset) / 8) + this.offset);
392
+ if (bits <= 0 || size_needed > this.size) {
393
+ throw new Error("Invalid number of bits to read: " + size_needed + " of " + this.size);
394
+ }
395
+ var off_in_bits = (this.offset * 8) + this.bitoffset;
396
+ var value = 0;
397
+ for (var i = 0; i < bits;) {
398
+ var remaining = bits - i;
399
+ var bitOffset = off_in_bits & 7;
400
+ var currentByte = this.data[off_in_bits >> 3];
401
+ var read = Math.min(remaining, 8 - bitOffset);
402
+ var mask, readBits;
403
+ if ((endian != undefined ? endian : this.endian) == "big") {
404
+ mask = ~(0xFF << read);
405
+ readBits = (currentByte >> (8 - read - bitOffset)) & mask;
406
+ value <<= read;
407
+ value |= readBits;
408
+ }
409
+ else {
410
+ mask = ~(0xFF << read);
411
+ readBits = (currentByte >> bitOffset) & mask;
412
+ value |= readBits << i;
413
+ }
414
+ off_in_bits += read;
415
+ i += read;
416
+ }
417
+ this.offset = this.offset + Math.floor(((bits) + this.bitoffset) / 8); //end byte
418
+ this.bitoffset = ((bits) + this.bitoffset) % 8;
419
+ if (unsigned == true) {
420
+ return value >>> 0;
421
+ }
422
+ if (bits !== 32 && value & (1 << (bits - 1))) {
423
+ value |= -1 ^ ((1 << bits) - 1);
424
+ }
425
+ return value;
426
+ }
427
+ /**
428
+ * Bit field reader
429
+ *
430
+ * Note: When returning to a byte read, remaining bits are dropped
431
+ *
432
+ * @param {number} bits - bits to read
433
+ * @param {boolean} unsigned - if the value is unsigned
434
+ * @param {string} endian - ``big`` or ``little`
435
+ * @returns number
436
+ */
437
+ bit(bits, unsigned, endian) {
438
+ return this.readBit(bits, unsigned, endian);
439
+ }
440
+ /**
441
+ * Bit field reader
442
+ *
443
+ * Note: When returning to a byte read, remaining bits are dropped
444
+ *
445
+ * @param {boolean} unsigned - if the value is unsigned
446
+ * @returns number
447
+ */
448
+ bit1(unsigned) {
449
+ return this.bit(1, unsigned);
450
+ }
451
+ /**
452
+ * Bit field reader
453
+ *
454
+ * Note: When returning to a byte read, remaining bits are dropped
455
+ *
456
+ * @param {boolean} unsigned - if the value is unsigned
457
+ * @returns number
458
+ */
459
+ bit1le(unsigned) {
460
+ return this.bit(1, unsigned, "little");
461
+ }
462
+ /**
463
+ * Bit field reader
464
+ *
465
+ * Note: When returning to a byte read, remaining bits are dropped
466
+ *
467
+ * @param {boolean} unsigned - if the value is unsigned
468
+ * @returns number
469
+ */
470
+ bit1be(unsigned) {
471
+ return this.bit(1, unsigned, "big");
472
+ }
473
+ /**
474
+ * Bit field reader
475
+ *
476
+ * Note: When returning to a byte read, remaining bits are dropped
477
+ *
478
+ * @returns number
479
+ */
480
+ ubit1() {
481
+ return this.bit(1, true);
482
+ }
483
+ /**
484
+ * Bit field reader
485
+ *
486
+ * Note: When returning to a byte read, remaining bits are dropped
487
+ *
488
+ * @returns number
489
+ */
490
+ ubit1le() {
491
+ return this.bit(1, true, "little");
492
+ }
493
+ /**
494
+ * Bit field reader
495
+ *
496
+ * Note: When returning to a byte read, remaining bits are dropped
497
+ *
498
+ * @returns number
499
+ */
500
+ ubit1be() {
501
+ return this.bit(1, true, "big");
502
+ }
503
+ /**
504
+ * Bit field reader
505
+ *
506
+ * Note: When returning to a byte read, remaining bits are dropped
507
+ *
508
+ * @param {boolean} unsigned - if the value is unsigned
509
+ * @returns number
510
+ */
511
+ bit2(unsigned) {
512
+ return this.bit(2, unsigned);
513
+ }
514
+ /**
515
+ * Bit field reader
516
+ *
517
+ * Note: When returning to a byte read, remaining bits are dropped
518
+ *
519
+ * @param {boolean} unsigned - if the value is unsigned
520
+ * @returns number
521
+ */
522
+ bit2le(unsigned) {
523
+ return this.bit(2, unsigned, "little");
524
+ }
525
+ /**
526
+ * Bit field reader
527
+ *
528
+ * Note: When returning to a byte read, remaining bits are dropped
529
+ *
530
+ * @param {boolean} unsigned - if the value is unsigned
531
+ * @returns number
532
+ */
533
+ bit2be(unsigned) {
534
+ return this.bit(2, unsigned, "big");
535
+ }
536
+ /**
537
+ * Bit field reader
538
+ *
539
+ * Note: When returning to a byte read, remaining bits are dropped
540
+ *
541
+ * @returns number
542
+ */
543
+ ubit2() {
544
+ return this.bit(2, true);
545
+ }
546
+ /**
547
+ * Bit field reader
548
+ *
549
+ * Note: When returning to a byte read, remaining bits are dropped
550
+ *
551
+ * @returns number
552
+ */
553
+ ubit2le() {
554
+ return this.bit(2, true, "little");
555
+ }
556
+ /**
557
+ * Bit field reader
558
+ *
559
+ * Note: When returning to a byte read, remaining bits are dropped
560
+ *
561
+ * @returns number
562
+ */
563
+ ubit2be() {
564
+ return this.bit(2, true, "big");
565
+ }
566
+ /**
567
+ * Bit field reader
568
+ *
569
+ * Note: When returning to a byte read, remaining bits are dropped
570
+ *
571
+ * @param {boolean} unsigned - if the value is unsigned
572
+ * @returns number
573
+ */
574
+ bit3(unsigned) {
575
+ return this.bit(3, unsigned);
576
+ }
577
+ /**
578
+ * Bit field reader
579
+ *
580
+ * Note: When returning to a byte read, remaining bits are dropped
581
+ *
582
+ * @param {boolean} unsigned - if the value is unsigned
583
+ * @returns number
584
+ */
585
+ bit3le(unsigned) {
586
+ return this.bit(3, unsigned, "little");
587
+ }
588
+ /**
589
+ * Bit field reader
590
+ *
591
+ * Note: When returning to a byte read, remaining bits are dropped
592
+ *
593
+ * @param {boolean} unsigned - if the value is unsigned
594
+ * @returns number
595
+ */
596
+ bit3be(unsigned) {
597
+ return this.bit(3, unsigned, "big");
598
+ }
599
+ /**
600
+ * Bit field reader
601
+ *
602
+ * Note: When returning to a byte read, remaining bits are dropped
603
+ *
604
+ * @returns number
605
+ */
606
+ ubit3() {
607
+ return this.bit(3, true);
608
+ }
609
+ /**
610
+ * Bit field reader
611
+ *
612
+ * Note: When returning to a byte read, remaining bits are dropped
613
+ *
614
+ * @returns number
615
+ */
616
+ ubit3le() {
617
+ return this.bit(3, true, "little");
618
+ }
619
+ /**
620
+ * Bit field reader
621
+ *
622
+ * Note: When returning to a byte read, remaining bits are dropped
623
+ *
624
+ * @returns number
625
+ */
626
+ ubit3be() {
627
+ return this.bit(3, true, "big");
628
+ }
629
+ /**
630
+ * Bit field reader
631
+ *
632
+ * Note: When returning to a byte read, remaining bits are dropped
633
+ *
634
+ * @param {boolean} unsigned - if the value is unsigned
635
+ * @returns number
636
+ */
637
+ bit4(unsigned) {
638
+ return this.bit(4, unsigned);
639
+ }
640
+ /**
641
+ * Bit field reader
642
+ *
643
+ * Note: When returning to a byte read, remaining bits are dropped
644
+ *
645
+ * @param {boolean} unsigned - if the value is unsigned
646
+ * @returns number
647
+ */
648
+ bit4le(unsigned) {
649
+ return this.bit(4, unsigned, "little");
650
+ }
651
+ /**
652
+ * Bit field reader
653
+ *
654
+ * Note: When returning to a byte read, remaining bits are dropped
655
+ *
656
+ * @param {boolean} unsigned - if the value is unsigned
657
+ * @returns number
658
+ */
659
+ bit4be(unsigned) {
660
+ return this.bit(4, unsigned, "big");
661
+ }
662
+ /**
663
+ * Bit field reader
664
+ *
665
+ * Note: When returning to a byte read, remaining bits are dropped
666
+ *
667
+ * @returns number
668
+ */
669
+ ubit4() {
670
+ return this.bit(4, true);
671
+ }
672
+ /**
673
+ * Bit field reader
674
+ *
675
+ * Note: When returning to a byte read, remaining bits are dropped
676
+ *
677
+ * @returns number
678
+ */
679
+ ubit4le() {
680
+ return this.bit(4, true, "little");
681
+ }
682
+ /**
683
+ * Bit field reader
684
+ *
685
+ * Note: When returning to a byte read, remaining bits are dropped
686
+ *
687
+ * @returns number
688
+ */
689
+ ubit4be() {
690
+ return this.bit(4, true, "big");
691
+ }
692
+ /**
693
+ * Bit field reader
694
+ *
695
+ * Note: When returning to a byte read, remaining bits are dropped
696
+ *
697
+ * @param {boolean} unsigned - if the value is unsigned
698
+ * @returns number
699
+ */
700
+ bit5(unsigned) {
701
+ return this.bit(5, unsigned);
702
+ }
703
+ /**
704
+ * Bit field reader
705
+ *
706
+ * Note: When returning to a byte read, remaining bits are dropped
707
+ *
708
+ * @param {boolean} unsigned - if the value is unsigned
709
+ * @returns number
710
+ */
711
+ bit5le(unsigned) {
712
+ return this.bit(5, unsigned, "little");
713
+ }
714
+ /**
715
+ * Bit field reader
716
+ *
717
+ * Note: When returning to a byte read, remaining bits are dropped
718
+ *
719
+ * @param {boolean} unsigned - if the value is unsigned
720
+ * @returns number
721
+ */
722
+ bit5be(unsigned) {
723
+ return this.bit(5, unsigned, "big");
724
+ }
725
+ /**
726
+ * Bit field reader
727
+ *
728
+ * Note: When returning to a byte read, remaining bits are dropped
729
+ *
730
+ * @returns number
731
+ */
732
+ ubit5() {
733
+ return this.bit(5, true);
734
+ }
735
+ /**
736
+ * Bit field reader
737
+ *
738
+ * Note: When returning to a byte read, remaining bits are dropped
739
+ *
740
+ * @returns number
741
+ */
742
+ ubit5le() {
743
+ return this.bit(5, true, "little");
744
+ }
745
+ /**
746
+ * Bit field reader
747
+ *
748
+ * Note: When returning to a byte read, remaining bits are dropped
749
+ *
750
+ * @returns number
751
+ */
752
+ ubit5be() {
753
+ return this.bit(5, true, "big");
754
+ }
755
+ /**
756
+ * Bit field reader
757
+ *
758
+ * Note: When returning to a byte read, remaining bits are dropped
759
+ *
760
+ * @param {boolean} unsigned - if the value is unsigned
761
+ * @returns number
762
+ */
763
+ bit6(unsigned) {
764
+ return this.bit(6, unsigned);
765
+ }
766
+ /**
767
+ * Bit field reader
768
+ *
769
+ * Note: When returning to a byte read, remaining bits are dropped
770
+ *
771
+ * @param {boolean} unsigned - if the value is unsigned
772
+ * @returns number
773
+ */
774
+ bit6le(unsigned) {
775
+ return this.bit(6, unsigned, "little");
776
+ }
777
+ /**
778
+ * Bit field reader
779
+ *
780
+ * Note: When returning to a byte read, remaining bits are dropped
781
+ *
782
+ * @param {boolean} unsigned - if the value is unsigned
783
+ * @returns number
784
+ */
785
+ bit6be(unsigned) {
786
+ return this.bit(6, unsigned, "big");
787
+ }
788
+ /**
789
+ * Bit field reader
790
+ *
791
+ * Note: When returning to a byte read, remaining bits are dropped
792
+ *
793
+ * @returns number
794
+ */
795
+ ubit6() {
796
+ return this.bit(6, true);
797
+ }
798
+ /**
799
+ * Bit field reader
800
+ *
801
+ * Note: When returning to a byte read, remaining bits are dropped
802
+ *
803
+ * @returns number
804
+ */
805
+ ubit6le() {
806
+ return this.bit(6, true, "little");
807
+ }
808
+ /**
809
+ * Bit field reader
810
+ *
811
+ * Note: When returning to a byte read, remaining bits are dropped
812
+ *
813
+ * @returns number
814
+ */
815
+ ubit6be() {
816
+ return this.bit(6, true, "big");
817
+ }
818
+ /**
819
+ * Bit field reader
820
+ *
821
+ * Note: When returning to a byte read, remaining bits are dropped
822
+ *
823
+ * @param {boolean} unsigned - if the value is unsigned
824
+ * @returns number
825
+ */
826
+ bit7(unsigned) {
827
+ return this.bit(7, unsigned);
828
+ }
829
+ /**
830
+ * Bit field reader
831
+ *
832
+ * Note: When returning to a byte read, remaining bits are dropped
833
+ *
834
+ * @param {boolean} unsigned - if the value is unsigned
835
+ * @returns number
836
+ */
837
+ bit7le(unsigned) {
838
+ return this.bit(7, unsigned, "little");
839
+ }
840
+ /**
841
+ * Bit field reader
842
+ *
843
+ * Note: When returning to a byte read, remaining bits are dropped
844
+ *
845
+ * @param {boolean} unsigned - if the value is unsigned
846
+ * @returns number
847
+ */
848
+ bit7be(unsigned) {
849
+ return this.bit(7, unsigned, "big");
850
+ }
851
+ /**
852
+ * Bit field reader
853
+ *
854
+ * Note: When returning to a byte read, remaining bits are dropped
855
+ *
856
+ * @returns number
857
+ */
858
+ ubit7() {
859
+ return this.bit(7, true);
860
+ }
861
+ /**
862
+ * Bit field reader
863
+ *
864
+ * Note: When returning to a byte read, remaining bits are dropped
865
+ *
866
+ * @returns number
867
+ */
868
+ ubit7le() {
869
+ return this.bit(7, true, "little");
870
+ }
871
+ /**
872
+ * Bit field reader
873
+ *
874
+ * Note: When returning to a byte read, remaining bits are dropped
875
+ *
876
+ * @returns number
877
+ */
878
+ ubit7be() {
879
+ return this.bit(7, true, "big");
880
+ }
881
+ /**
882
+ * Bit field reader
883
+ *
884
+ * Note: When returning to a byte read, remaining bits are dropped
885
+ *
886
+ * @param {boolean} unsigned - if the value is unsigned
887
+ * @returns number
888
+ */
889
+ bit8(unsigned) {
890
+ return this.bit(8, unsigned);
891
+ }
892
+ /**
893
+ * Bit field reader
894
+ *
895
+ * Note: When returning to a byte read, remaining bits are dropped
896
+ *
897
+ * @param {boolean} unsigned - if the value is unsigned
898
+ * @returns number
899
+ */
900
+ bit8le(unsigned) {
901
+ return this.bit(8, unsigned, "little");
902
+ }
903
+ /**
904
+ * Bit field reader
905
+ *
906
+ * Note: When returning to a byte read, remaining bits are dropped
907
+ *
908
+ * @param {boolean} unsigned - if the value is unsigned
909
+ * @returns number
910
+ */
911
+ bit8be(unsigned) {
912
+ return this.bit(8, unsigned, "big");
913
+ }
914
+ /**
915
+ * Bit field reader
916
+ *
917
+ * Note: When returning to a byte read, remaining bits are dropped
918
+ *
919
+ * @returns number
920
+ */
921
+ ubit8() {
922
+ return this.bit(8, true);
923
+ }
924
+ /**
925
+ * Bit field reader
926
+ *
927
+ * Note: When returning to a byte read, remaining bits are dropped
928
+ *
929
+ * @returns number
930
+ */
931
+ ubit8le() {
932
+ return this.bit(8, true, "little");
933
+ }
934
+ /**
935
+ * Bit field reader
936
+ *
937
+ * Note: When returning to a byte read, remaining bits are dropped
938
+ *
939
+ * @returns number
940
+ */
941
+ ubit8be() {
942
+ return this.bit(8, true, "big");
943
+ }
944
+ /**
945
+ * Bit field reader
946
+ *
947
+ * Note: When returning to a byte read, remaining bits are dropped
948
+ *
949
+ * @param {boolean} unsigned - if the value is unsigned
950
+ * @returns number
951
+ */
952
+ bit9(unsigned) {
953
+ return this.bit(9, unsigned);
954
+ }
955
+ /**
956
+ * Bit field reader
957
+ *
958
+ * Note: When returning to a byte read, remaining bits are dropped
959
+ *
960
+ * @param {boolean} unsigned - if the value is unsigned
961
+ * @returns number
962
+ */
963
+ bit9le(unsigned) {
964
+ return this.bit(9, unsigned, "little");
965
+ }
966
+ /**
967
+ * Bit field reader
968
+ *
969
+ * Note: When returning to a byte read, remaining bits are dropped
970
+ *
971
+ * @param {boolean} unsigned - if the value is unsigned
972
+ * @returns number
973
+ */
974
+ bit9be(unsigned) {
975
+ return this.bit(9, unsigned, "big");
976
+ }
977
+ /**
978
+ * Bit field reader
979
+ *
980
+ * Note: When returning to a byte read, remaining bits are dropped
981
+ *
982
+ * @returns number
983
+ */
984
+ ubit9() {
985
+ return this.bit(9, true);
986
+ }
987
+ /**
988
+ * Bit field reader
989
+ *
990
+ * Note: When returning to a byte read, remaining bits are dropped
991
+ *
992
+ * @returns number
993
+ */
994
+ ubit9le() {
995
+ return this.bit(9, true, "little");
996
+ }
997
+ /**
998
+ * Bit field reader
999
+ *
1000
+ * Note: When returning to a byte read, remaining bits are dropped
1001
+ *
1002
+ * @returns number
1003
+ */
1004
+ ubit9be() {
1005
+ return this.bit(9, true, "big");
1006
+ }
1007
+ /**
1008
+ * Bit field reader
1009
+ *
1010
+ * Note: When returning to a byte read, remaining bits are dropped
1011
+ *
1012
+ * @param {boolean} unsigned - if the value is unsigned
1013
+ * @returns number
1014
+ */
1015
+ bit10(unsigned) {
1016
+ return this.bit(10, unsigned);
1017
+ }
1018
+ /**
1019
+ * Bit field reader
1020
+ *
1021
+ * Note: When returning to a byte read, remaining bits are dropped
1022
+ *
1023
+ * @param {boolean} unsigned - if the value is unsigned
1024
+ * @returns number
1025
+ */
1026
+ bit10le(unsigned) {
1027
+ return this.bit(10, unsigned, "little");
1028
+ }
1029
+ /**
1030
+ * Bit field reader
1031
+ *
1032
+ * Note: When returning to a byte read, remaining bits are dropped
1033
+ *
1034
+ * @param {boolean} unsigned - if the value is unsigned
1035
+ * @returns number
1036
+ */
1037
+ bit10be(unsigned) {
1038
+ return this.bit(10, unsigned, "big");
1039
+ }
1040
+ /**
1041
+ * Bit field reader
1042
+ *
1043
+ * Note: When returning to a byte read, remaining bits are dropped
1044
+ *
1045
+ * @returns number
1046
+ */
1047
+ ubit10() {
1048
+ return this.bit(10, true);
1049
+ }
1050
+ /**
1051
+ * Bit field reader
1052
+ *
1053
+ * Note: When returning to a byte read, remaining bits are dropped
1054
+ *
1055
+ * @returns number
1056
+ */
1057
+ ubit10le() {
1058
+ return this.bit(10, true, "little");
1059
+ }
1060
+ /**
1061
+ * Bit field reader
1062
+ *
1063
+ * Note: When returning to a byte read, remaining bits are dropped
1064
+ *
1065
+ * @returns number
1066
+ */
1067
+ ubit10be() {
1068
+ return this.bit(10, true, "big");
1069
+ }
1070
+ /**
1071
+ * Bit field reader
1072
+ *
1073
+ * Note: When returning to a byte read, remaining bits are dropped
1074
+ *
1075
+ * @param {boolean} unsigned - if the value is unsigned
1076
+ * @returns number
1077
+ */
1078
+ bit11(unsigned) {
1079
+ return this.bit(11, unsigned);
1080
+ }
1081
+ /**
1082
+ * Bit field reader
1083
+ *
1084
+ * Note: When returning to a byte read, remaining bits are dropped
1085
+ *
1086
+ * @param {boolean} unsigned - if the value is unsigned
1087
+ * @returns number
1088
+ */
1089
+ bit11le(unsigned) {
1090
+ return this.bit(11, unsigned, "little");
1091
+ }
1092
+ /**
1093
+ * Bit field reader
1094
+ *
1095
+ * Note: When returning to a byte read, remaining bits are dropped
1096
+ *
1097
+ * @param {boolean} unsigned - if the value is unsigned
1098
+ * @returns number
1099
+ */
1100
+ bit11be(unsigned) {
1101
+ return this.bit(11, unsigned, "big");
1102
+ }
1103
+ /**
1104
+ * Bit field reader
1105
+ *
1106
+ * Note: When returning to a byte read, remaining bits are dropped
1107
+ *
1108
+ * @returns number
1109
+ */
1110
+ ubit11() {
1111
+ return this.bit(11, true);
1112
+ }
1113
+ /**
1114
+ * Bit field reader
1115
+ *
1116
+ * Note: When returning to a byte read, remaining bits are dropped
1117
+ *
1118
+ * @returns number
1119
+ */
1120
+ ubit11le() {
1121
+ return this.bit(11, true, "little");
1122
+ }
1123
+ /**
1124
+ * Bit field reader
1125
+ *
1126
+ * Note: When returning to a byte read, remaining bits are dropped
1127
+ *
1128
+ * @returns number
1129
+ */
1130
+ ubit11be() {
1131
+ return this.bit(11, true, "big");
1132
+ }
1133
+ /**
1134
+ * Bit field reader
1135
+ *
1136
+ * Note: When returning to a byte read, remaining bits are dropped
1137
+ *
1138
+ * @param {boolean} unsigned - if the value is unsigned
1139
+ * @returns number
1140
+ */
1141
+ bit12(unsigned) {
1142
+ return this.bit(12, unsigned);
1143
+ }
1144
+ /**
1145
+ * Bit field reader
1146
+ *
1147
+ * Note: When returning to a byte read, remaining bits are dropped
1148
+ *
1149
+ * @param {boolean} unsigned - if the value is unsigned
1150
+ * @returns number
1151
+ */
1152
+ bit12le(unsigned) {
1153
+ return this.bit(12, unsigned, "little");
1154
+ }
1155
+ /**
1156
+ * Bit field reader
1157
+ *
1158
+ * Note: When returning to a byte read, remaining bits are dropped
1159
+ *
1160
+ * @param {boolean} unsigned - if the value is unsigned
1161
+ * @returns number
1162
+ */
1163
+ bit12be(unsigned) {
1164
+ return this.bit(12, unsigned, "big");
1165
+ }
1166
+ /**
1167
+ * Bit field reader
1168
+ *
1169
+ * Note: When returning to a byte read, remaining bits are dropped
1170
+ *
1171
+ * @returns number
1172
+ */
1173
+ ubit12() {
1174
+ return this.bit(12, true);
1175
+ }
1176
+ /**
1177
+ * Bit field reader
1178
+ *
1179
+ * Note: When returning to a byte read, remaining bits are dropped
1180
+ *
1181
+ * @returns number
1182
+ */
1183
+ ubit12le() {
1184
+ return this.bit(12, true, "little");
1185
+ }
1186
+ /**
1187
+ * Bit field reader
1188
+ *
1189
+ * Note: When returning to a byte read, remaining bits are dropped
1190
+ *
1191
+ * @returns number
1192
+ */
1193
+ ubit12be() {
1194
+ return this.bit(12, true, "big");
1195
+ }
1196
+ /**
1197
+ * Bit field reader
1198
+ *
1199
+ * Note: When returning to a byte read, remaining bits are dropped
1200
+ *
1201
+ * @param {boolean} unsigned - if the value is unsigned
1202
+ * @returns number
1203
+ */
1204
+ bit13(unsigned) {
1205
+ return this.bit(13, unsigned);
1206
+ }
1207
+ /**
1208
+ * Bit field reader
1209
+ *
1210
+ * Note: When returning to a byte read, remaining bits are dropped
1211
+ *
1212
+ * @param {boolean} unsigned - if the value is unsigned
1213
+ * @returns number
1214
+ */
1215
+ bit13le(unsigned) {
1216
+ return this.bit(13, unsigned, "little");
1217
+ }
1218
+ /**
1219
+ * Bit field reader
1220
+ *
1221
+ * Note: When returning to a byte read, remaining bits are dropped
1222
+ *
1223
+ * @param {boolean} unsigned - if the value is unsigned
1224
+ * @returns number
1225
+ */
1226
+ bit13be(unsigned) {
1227
+ return this.bit(13, unsigned, "big");
1228
+ }
1229
+ /**
1230
+ * Bit field reader
1231
+ *
1232
+ * Note: When returning to a byte read, remaining bits are dropped
1233
+ *
1234
+ * @returns number
1235
+ */
1236
+ ubit13() {
1237
+ return this.bit(13, true);
1238
+ }
1239
+ /**
1240
+ * Bit field reader
1241
+ *
1242
+ * Note: When returning to a byte read, remaining bits are dropped
1243
+ *
1244
+ * @returns number
1245
+ */
1246
+ ubit13le() {
1247
+ return this.bit(13, true, "little");
1248
+ }
1249
+ /**
1250
+ * Bit field reader
1251
+ *
1252
+ * Note: When returning to a byte read, remaining bits are dropped
1253
+ *
1254
+ * @returns number
1255
+ */
1256
+ ubit13be() {
1257
+ return this.bit(13, true, "big");
1258
+ }
1259
+ /**
1260
+ * Bit field reader
1261
+ *
1262
+ * Note: When returning to a byte read, remaining bits are dropped
1263
+ *
1264
+ * @param {boolean} unsigned - if the value is unsigned
1265
+ * @returns number
1266
+ */
1267
+ bit14(unsigned) {
1268
+ return this.bit(14, unsigned);
1269
+ }
1270
+ /**
1271
+ * Bit field reader
1272
+ *
1273
+ * Note: When returning to a byte read, remaining bits are dropped
1274
+ *
1275
+ * @param {boolean} unsigned - if the value is unsigned
1276
+ * @returns number
1277
+ */
1278
+ bit14le(unsigned) {
1279
+ return this.bit(14, unsigned, "little");
1280
+ }
1281
+ /**
1282
+ * Bit field reader
1283
+ *
1284
+ * Note: When returning to a byte read, remaining bits are dropped
1285
+ *
1286
+ * @param {boolean} unsigned - if the value is unsigned
1287
+ * @returns number
1288
+ */
1289
+ bit14be(unsigned) {
1290
+ return this.bit(14, unsigned, "big");
1291
+ }
1292
+ /**
1293
+ * Bit field reader
1294
+ *
1295
+ * Note: When returning to a byte read, remaining bits are dropped
1296
+ *
1297
+ * @returns number
1298
+ */
1299
+ ubit14() {
1300
+ return this.bit(14, true);
1301
+ }
1302
+ /**
1303
+ * Bit field reader
1304
+ *
1305
+ * Note: When returning to a byte read, remaining bits are dropped
1306
+ *
1307
+ * @returns number
1308
+ */
1309
+ ubit14le() {
1310
+ return this.bit(14, true, "little");
1311
+ }
1312
+ /**
1313
+ * Bit field reader
1314
+ *
1315
+ * Note: When returning to a byte read, remaining bits are dropped
1316
+ *
1317
+ * @returns number
1318
+ */
1319
+ ubit14be() {
1320
+ return this.bit(14, true, "big");
1321
+ }
1322
+ /**
1323
+ * Bit field reader
1324
+ *
1325
+ * Note: When returning to a byte read, remaining bits are dropped
1326
+ *
1327
+ * @param {boolean} unsigned - if the value is unsigned
1328
+ * @returns number
1329
+ */
1330
+ bit15(unsigned) {
1331
+ return this.bit(15, unsigned);
1332
+ }
1333
+ /**
1334
+ * Bit field reader
1335
+ *
1336
+ * Note: When returning to a byte read, remaining bits are dropped
1337
+ *
1338
+ * @param {boolean} unsigned - if the value is unsigned
1339
+ * @returns number
1340
+ */
1341
+ bit15le(unsigned) {
1342
+ return this.bit(15, unsigned, "little");
1343
+ }
1344
+ /**
1345
+ * Bit field reader
1346
+ *
1347
+ * Note: When returning to a byte read, remaining bits are dropped
1348
+ *
1349
+ * @param {boolean} unsigned - if the value is unsigned
1350
+ * @returns number
1351
+ */
1352
+ bit15be(unsigned) {
1353
+ return this.bit(15, unsigned, "big");
1354
+ }
1355
+ /**
1356
+ * Bit field reader
1357
+ *
1358
+ * Note: When returning to a byte read, remaining bits are dropped
1359
+ *
1360
+ * @returns number
1361
+ */
1362
+ ubit15() {
1363
+ return this.bit(15, true);
1364
+ }
1365
+ /**
1366
+ * Bit field reader
1367
+ *
1368
+ * Note: When returning to a byte read, remaining bits are dropped
1369
+ *
1370
+ * @returns number
1371
+ */
1372
+ ubit15le() {
1373
+ return this.bit(15, true, "little");
1374
+ }
1375
+ /**
1376
+ * Bit field reader
1377
+ *
1378
+ * Note: When returning to a byte read, remaining bits are dropped
1379
+ *
1380
+ * @returns number
1381
+ */
1382
+ ubit15be() {
1383
+ return this.bit(15, true, "big");
1384
+ }
1385
+ /**
1386
+ * Bit field reader
1387
+ *
1388
+ * Note: When returning to a byte read, remaining bits are dropped
1389
+ *
1390
+ * @param {boolean} unsigned - if the value is unsigned
1391
+ * @returns number
1392
+ */
1393
+ bit16(unsigned) {
1394
+ return this.bit(16, unsigned);
1395
+ }
1396
+ /**
1397
+ * Bit field reader
1398
+ *
1399
+ * Note: When returning to a byte read, remaining bits are dropped
1400
+ *
1401
+ * @param {boolean} unsigned - if the value is unsigned
1402
+ * @returns number
1403
+ */
1404
+ bit16le(unsigned) {
1405
+ return this.bit(16, unsigned, "little");
1406
+ }
1407
+ /**
1408
+ * Bit field reader
1409
+ *
1410
+ * Note: When returning to a byte read, remaining bits are dropped
1411
+ *
1412
+ * @param {boolean} unsigned - if the value is unsigned
1413
+ * @returns number
1414
+ */
1415
+ bit16be(unsigned) {
1416
+ return this.bit(16, unsigned, "big");
1417
+ }
1418
+ /**
1419
+ * Bit field reader
1420
+ *
1421
+ * Note: When returning to a byte read, remaining bits are dropped
1422
+ *
1423
+ * @returns number
1424
+ */
1425
+ ubit16() {
1426
+ return this.bit(16, true);
1427
+ }
1428
+ /**
1429
+ * Bit field reader
1430
+ *
1431
+ * Note: When returning to a byte read, remaining bits are dropped
1432
+ *
1433
+ * @returns number
1434
+ */
1435
+ ubit16le() {
1436
+ return this.bit(16, true, "little");
1437
+ }
1438
+ /**
1439
+ * Bit field reader
1440
+ *
1441
+ * Note: When returning to a byte read, remaining bits are dropped
1442
+ *
1443
+ * @returns number
1444
+ */
1445
+ ubit16be() {
1446
+ return this.bit(16, true, "big");
1447
+ }
1448
+ /**
1449
+ * Bit field reader
1450
+ *
1451
+ * Note: When returning to a byte read, remaining bits are dropped
1452
+ *
1453
+ * @param {boolean} unsigned - if the value is unsigned
1454
+ * @returns number
1455
+ */
1456
+ bit17(unsigned) {
1457
+ return this.bit(17, unsigned);
1458
+ }
1459
+ /**
1460
+ * Bit field reader
1461
+ *
1462
+ * Note: When returning to a byte read, remaining bits are dropped
1463
+ *
1464
+ * @param {boolean} unsigned - if the value is unsigned
1465
+ * @returns number
1466
+ */
1467
+ bit17le(unsigned) {
1468
+ return this.bit(17, unsigned, "little");
1469
+ }
1470
+ /**
1471
+ * Bit field reader
1472
+ *
1473
+ * Note: When returning to a byte read, remaining bits are dropped
1474
+ *
1475
+ * @param {boolean} unsigned - if the value is unsigned
1476
+ * @returns number
1477
+ */
1478
+ bit17be(unsigned) {
1479
+ return this.bit(17, unsigned, "big");
1480
+ }
1481
+ /**
1482
+ * Bit field reader
1483
+ *
1484
+ * Note: When returning to a byte read, remaining bits are dropped
1485
+ *
1486
+ * @returns number
1487
+ */
1488
+ ubit17() {
1489
+ return this.bit(17, true);
1490
+ }
1491
+ /**
1492
+ * Bit field reader
1493
+ *
1494
+ * Note: When returning to a byte read, remaining bits are dropped
1495
+ *
1496
+ * @returns number
1497
+ */
1498
+ ubit17le() {
1499
+ return this.bit(17, true, "little");
1500
+ }
1501
+ /**
1502
+ * Bit field reader
1503
+ *
1504
+ * Note: When returning to a byte read, remaining bits are dropped
1505
+ *
1506
+ * @returns number
1507
+ */
1508
+ ubit17be() {
1509
+ return this.bit(17, true, "big");
1510
+ }
1511
+ /**
1512
+ * Bit field reader
1513
+ *
1514
+ * Note: When returning to a byte read, remaining bits are dropped
1515
+ *
1516
+ * @param {boolean} unsigned - if the value is unsigned
1517
+ * @returns number
1518
+ */
1519
+ bit18(unsigned) {
1520
+ return this.bit(18, unsigned);
1521
+ }
1522
+ /**
1523
+ * Bit field reader
1524
+ *
1525
+ * Note: When returning to a byte read, remaining bits are dropped
1526
+ *
1527
+ * @param {boolean} unsigned - if the value is unsigned
1528
+ * @returns number
1529
+ */
1530
+ bit18le(unsigned) {
1531
+ return this.bit(18, unsigned, "little");
1532
+ }
1533
+ /**
1534
+ * Bit field reader
1535
+ *
1536
+ * Note: When returning to a byte read, remaining bits are dropped
1537
+ *
1538
+ * @param {boolean} unsigned - if the value is unsigned
1539
+ * @returns number
1540
+ */
1541
+ bit18be(unsigned) {
1542
+ return this.bit(18, unsigned, "big");
1543
+ }
1544
+ /**
1545
+ * Bit field reader
1546
+ *
1547
+ * Note: When returning to a byte read, remaining bits are dropped
1548
+ *
1549
+ * @returns number
1550
+ */
1551
+ ubit18() {
1552
+ return this.bit(18, true);
1553
+ }
1554
+ /**
1555
+ * Bit field reader
1556
+ *
1557
+ * Note: When returning to a byte read, remaining bits are dropped
1558
+ *
1559
+ * @returns number
1560
+ */
1561
+ ubit18le() {
1562
+ return this.bit(18, true, "little");
1563
+ }
1564
+ /**
1565
+ * Bit field reader
1566
+ *
1567
+ * Note: When returning to a byte read, remaining bits are dropped
1568
+ *
1569
+ * @returns number
1570
+ */
1571
+ ubit18be() {
1572
+ return this.bit(18, true, "big");
1573
+ }
1574
+ /**
1575
+ * Bit field reader
1576
+ *
1577
+ * Note: When returning to a byte read, remaining bits are dropped
1578
+ *
1579
+ * @param {boolean} unsigned - if the value is unsigned
1580
+ * @returns number
1581
+ */
1582
+ bit19(unsigned) {
1583
+ return this.bit(19, unsigned);
1584
+ }
1585
+ /**
1586
+ * Bit field reader
1587
+ *
1588
+ * Note: When returning to a byte read, remaining bits are dropped
1589
+ *
1590
+ * @param {boolean} unsigned - if the value is unsigned
1591
+ * @returns number
1592
+ */
1593
+ bit19le(unsigned) {
1594
+ return this.bit(19, unsigned, "little");
1595
+ }
1596
+ /**
1597
+ * Bit field reader
1598
+ *
1599
+ * Note: When returning to a byte read, remaining bits are dropped
1600
+ *
1601
+ * @param {boolean} unsigned - if the value is unsigned
1602
+ * @returns number
1603
+ */
1604
+ bit19be(unsigned) {
1605
+ return this.bit(19, unsigned, "big");
1606
+ }
1607
+ /**
1608
+ * Bit field reader
1609
+ *
1610
+ * Note: When returning to a byte read, remaining bits are dropped
1611
+ *
1612
+ * @returns number
1613
+ */
1614
+ ubit19() {
1615
+ return this.bit(19, true);
1616
+ }
1617
+ /**
1618
+ * Bit field reader
1619
+ *
1620
+ * Note: When returning to a byte read, remaining bits are dropped
1621
+ *
1622
+ * @returns number
1623
+ */
1624
+ ubit19le() {
1625
+ return this.bit(19, true, "little");
1626
+ }
1627
+ /**
1628
+ * Bit field reader
1629
+ *
1630
+ * Note: When returning to a byte read, remaining bits are dropped
1631
+ *
1632
+ * @returns number
1633
+ */
1634
+ ubit19be() {
1635
+ return this.bit(19, true, "big");
1636
+ }
1637
+ /**
1638
+ * Bit field reader
1639
+ *
1640
+ * Note: When returning to a byte read, remaining bits are dropped
1641
+ *
1642
+ * @param {boolean} unsigned - if the value is unsigned
1643
+ * @returns number
1644
+ */
1645
+ bit20(unsigned) {
1646
+ return this.bit(20, unsigned);
1647
+ }
1648
+ /**
1649
+ * Bit field reader
1650
+ *
1651
+ * Note: When returning to a byte read, remaining bits are dropped
1652
+ *
1653
+ * @param {boolean} unsigned - if the value is unsigned
1654
+ * @returns number
1655
+ */
1656
+ bit20le(unsigned) {
1657
+ return this.bit(20, unsigned, "little");
1658
+ }
1659
+ /**
1660
+ * Bit field reader
1661
+ *
1662
+ * Note: When returning to a byte read, remaining bits are dropped
1663
+ *
1664
+ * @param {boolean} unsigned - if the value is unsigned
1665
+ * @returns number
1666
+ */
1667
+ bit20be(unsigned) {
1668
+ return this.bit(20, unsigned, "big");
1669
+ }
1670
+ /**
1671
+ * Bit field reader
1672
+ *
1673
+ * Note: When returning to a byte read, remaining bits are dropped
1674
+ *
1675
+ * @returns number
1676
+ */
1677
+ ubit20() {
1678
+ return this.bit(20, true);
1679
+ }
1680
+ /**
1681
+ * Bit field reader
1682
+ *
1683
+ * Note: When returning to a byte read, remaining bits are dropped
1684
+ *
1685
+ * @returns number
1686
+ */
1687
+ ubit20le() {
1688
+ return this.bit(20, true, "little");
1689
+ }
1690
+ /**
1691
+ * Bit field reader
1692
+ *
1693
+ * Note: When returning to a byte read, remaining bits are dropped
1694
+ *
1695
+ * @returns number
1696
+ */
1697
+ ubit20be() {
1698
+ return this.bit(20, true, "big");
1699
+ }
1700
+ /**
1701
+ * Bit field reader
1702
+ *
1703
+ * Note: When returning to a byte read, remaining bits are dropped
1704
+ *
1705
+ * @param {boolean} unsigned - if the value is unsigned
1706
+ * @returns number
1707
+ */
1708
+ bit21(unsigned) {
1709
+ return this.bit(21, unsigned);
1710
+ }
1711
+ /**
1712
+ * Bit field reader
1713
+ *
1714
+ * Note: When returning to a byte read, remaining bits are dropped
1715
+ *
1716
+ * @param {boolean} unsigned - if the value is unsigned
1717
+ * @returns number
1718
+ */
1719
+ bit21le(unsigned) {
1720
+ return this.bit(21, unsigned, "little");
1721
+ }
1722
+ /**
1723
+ * Bit field reader
1724
+ *
1725
+ * Note: When returning to a byte read, remaining bits are dropped
1726
+ *
1727
+ * @param {boolean} unsigned - if the value is unsigned
1728
+ * @returns number
1729
+ */
1730
+ bit21be(unsigned) {
1731
+ return this.bit(21, unsigned, "big");
1732
+ }
1733
+ /**
1734
+ * Bit field reader
1735
+ *
1736
+ * Note: When returning to a byte read, remaining bits are dropped
1737
+ *
1738
+ * @returns number
1739
+ */
1740
+ ubit21() {
1741
+ return this.bit(21, true);
1742
+ }
1743
+ /**
1744
+ * Bit field reader
1745
+ *
1746
+ * Note: When returning to a byte read, remaining bits are dropped
1747
+ *
1748
+ * @returns number
1749
+ */
1750
+ ubit21le() {
1751
+ return this.bit(21, true, "little");
1752
+ }
1753
+ /**
1754
+ * Bit field reader
1755
+ *
1756
+ * Note: When returning to a byte read, remaining bits are dropped
1757
+ *
1758
+ * @returns number
1759
+ */
1760
+ ubit21be() {
1761
+ return this.bit(21, true, "big");
1762
+ }
1763
+ /**
1764
+ * Bit field reader
1765
+ *
1766
+ * Note: When returning to a byte read, remaining bits are dropped
1767
+ *
1768
+ * @param {boolean} unsigned - if the value is unsigned
1769
+ * @returns number
1770
+ */
1771
+ bit22(unsigned) {
1772
+ return this.bit(22, unsigned);
1773
+ }
1774
+ /**
1775
+ * Bit field reader
1776
+ *
1777
+ * Note: When returning to a byte read, remaining bits are dropped
1778
+ *
1779
+ * @param {boolean} unsigned - if the value is unsigned
1780
+ * @returns number
1781
+ */
1782
+ bit22le(unsigned) {
1783
+ return this.bit(22, unsigned, "little");
1784
+ }
1785
+ /**
1786
+ * Bit field reader
1787
+ *
1788
+ * Note: When returning to a byte read, remaining bits are dropped
1789
+ *
1790
+ * @param {boolean} unsigned - if the value is unsigned
1791
+ * @returns number
1792
+ */
1793
+ bit22be(unsigned) {
1794
+ return this.bit(22, unsigned, "big");
1795
+ }
1796
+ /**
1797
+ * Bit field reader
1798
+ *
1799
+ * Note: When returning to a byte read, remaining bits are dropped
1800
+ *
1801
+ * @returns number
1802
+ */
1803
+ ubit22() {
1804
+ return this.bit(22, true);
1805
+ }
1806
+ /**
1807
+ * Bit field reader
1808
+ *
1809
+ * Note: When returning to a byte read, remaining bits are dropped
1810
+ *
1811
+ * @returns number
1812
+ */
1813
+ ubit22le() {
1814
+ return this.bit(22, true, "little");
1815
+ }
1816
+ /**
1817
+ * Bit field reader
1818
+ *
1819
+ * Note: When returning to a byte read, remaining bits are dropped
1820
+ *
1821
+ * @returns number
1822
+ */
1823
+ ubit22be() {
1824
+ return this.bit(22, true, "big");
1825
+ }
1826
+ /**
1827
+ * Bit field reader
1828
+ *
1829
+ * Note: When returning to a byte read, remaining bits are dropped
1830
+ *
1831
+ * @param {boolean} unsigned - if the value is unsigned
1832
+ * @returns number
1833
+ */
1834
+ bit23(unsigned) {
1835
+ return this.bit(23, unsigned);
1836
+ }
1837
+ /**
1838
+ * Bit field reader
1839
+ *
1840
+ * Note: When returning to a byte read, remaining bits are dropped
1841
+ *
1842
+ * @param {boolean} unsigned - if the value is unsigned
1843
+ * @returns number
1844
+ */
1845
+ bit23le(unsigned) {
1846
+ return this.bit(23, unsigned, "little");
1847
+ }
1848
+ /**
1849
+ * Bit field reader
1850
+ *
1851
+ * Note: When returning to a byte read, remaining bits are dropped
1852
+ *
1853
+ * @param {boolean} unsigned - if the value is unsigned
1854
+ * @returns number
1855
+ */
1856
+ bit23be(unsigned) {
1857
+ return this.bit(23, unsigned, "big");
1858
+ }
1859
+ /**
1860
+ * Bit field reader
1861
+ *
1862
+ * Note: When returning to a byte read, remaining bits are dropped
1863
+ *
1864
+ * @returns number
1865
+ */
1866
+ ubit23() {
1867
+ return this.bit(23, true);
1868
+ }
1869
+ /**
1870
+ * Bit field reader
1871
+ *
1872
+ * Note: When returning to a byte read, remaining bits are dropped
1873
+ *
1874
+ * @returns number
1875
+ */
1876
+ ubit23le() {
1877
+ return this.bit(23, true, "little");
1878
+ }
1879
+ /**
1880
+ * Bit field reader
1881
+ *
1882
+ * Note: When returning to a byte read, remaining bits are dropped
1883
+ *
1884
+ * @returns number
1885
+ */
1886
+ ubit23be() {
1887
+ return this.bit(23, true, "big");
1888
+ }
1889
+ /**
1890
+ * Bit field reader
1891
+ *
1892
+ * Note: When returning to a byte read, remaining bits are dropped
1893
+ *
1894
+ * @param {boolean} unsigned - if the value is unsigned
1895
+ * @returns number
1896
+ */
1897
+ bit24(unsigned) {
1898
+ return this.bit(24, unsigned);
1899
+ }
1900
+ /**
1901
+ * Bit field reader
1902
+ *
1903
+ * Note: When returning to a byte read, remaining bits are dropped
1904
+ *
1905
+ * @param {boolean} unsigned - if the value is unsigned
1906
+ * @returns number
1907
+ */
1908
+ bit24le(unsigned) {
1909
+ return this.bit(24, unsigned, "little");
1910
+ }
1911
+ /**
1912
+ * Bit field reader
1913
+ *
1914
+ * Note: When returning to a byte read, remaining bits are dropped
1915
+ *
1916
+ * @param {boolean} unsigned - if the value is unsigned
1917
+ * @returns number
1918
+ */
1919
+ bit24be(unsigned) {
1920
+ return this.bit(24, unsigned, "big");
1921
+ }
1922
+ /**
1923
+ * Bit field reader
1924
+ *
1925
+ * Note: When returning to a byte read, remaining bits are dropped
1926
+ *
1927
+ * @returns number
1928
+ */
1929
+ ubit24() {
1930
+ return this.bit(24, true);
1931
+ }
1932
+ /**
1933
+ * Bit field reader
1934
+ *
1935
+ * Note: When returning to a byte read, remaining bits are dropped
1936
+ *
1937
+ * @returns number
1938
+ */
1939
+ ubit24le() {
1940
+ return this.bit(24, true, "little");
1941
+ }
1942
+ /**
1943
+ * Bit field reader
1944
+ *
1945
+ * Note: When returning to a byte read, remaining bits are dropped
1946
+ *
1947
+ * @returns number
1948
+ */
1949
+ ubit24be() {
1950
+ return this.bit(24, true, "big");
1951
+ }
1952
+ /**
1953
+ * Bit field reader
1954
+ *
1955
+ * Note: When returning to a byte read, remaining bits are dropped
1956
+ *
1957
+ * @param {boolean} unsigned - if the value is unsigned
1958
+ * @returns number
1959
+ */
1960
+ bit25(unsigned) {
1961
+ return this.bit(25, unsigned);
1962
+ }
1963
+ /**
1964
+ * Bit field reader
1965
+ *
1966
+ * Note: When returning to a byte read, remaining bits are dropped
1967
+ *
1968
+ * @param {boolean} unsigned - if the value is unsigned
1969
+ * @returns number
1970
+ */
1971
+ bit25le(unsigned) {
1972
+ return this.bit(25, unsigned, "little");
1973
+ }
1974
+ /**
1975
+ * Bit field reader
1976
+ *
1977
+ * Note: When returning to a byte read, remaining bits are dropped
1978
+ *
1979
+ * @param {boolean} unsigned - if the value is unsigned
1980
+ * @returns number
1981
+ */
1982
+ bit25be(unsigned) {
1983
+ return this.bit(25, unsigned, "big");
1984
+ }
1985
+ /**
1986
+ * Bit field reader
1987
+ *
1988
+ * Note: When returning to a byte read, remaining bits are dropped
1989
+ *
1990
+ * @returns number
1991
+ */
1992
+ ubit25() {
1993
+ return this.bit(25, true);
1994
+ }
1995
+ /**
1996
+ * Bit field reader
1997
+ *
1998
+ * Note: When returning to a byte read, remaining bits are dropped
1999
+ *
2000
+ * @returns number
2001
+ */
2002
+ ubit25le() {
2003
+ return this.bit(25, true, "little");
2004
+ }
2005
+ /**
2006
+ * Bit field reader
2007
+ *
2008
+ * Note: When returning to a byte read, remaining bits are dropped
2009
+ *
2010
+ * @returns number
2011
+ */
2012
+ ubit25be() {
2013
+ return this.bit(25, true, "big");
2014
+ }
2015
+ /**
2016
+ * Bit field reader
2017
+ *
2018
+ * Note: When returning to a byte read, remaining bits are dropped
2019
+ *
2020
+ * @param {boolean} unsigned - if the value is unsigned
2021
+ * @returns number
2022
+ */
2023
+ bit26(unsigned) {
2024
+ return this.bit(26, unsigned);
2025
+ }
2026
+ /**
2027
+ * Bit field reader
2028
+ *
2029
+ * Note: When returning to a byte read, remaining bits are dropped
2030
+ *
2031
+ * @param {boolean} unsigned - if the value is unsigned
2032
+ * @returns number
2033
+ */
2034
+ bit26le(unsigned) {
2035
+ return this.bit(26, unsigned, "little");
2036
+ }
2037
+ /**
2038
+ * Bit field reader
2039
+ *
2040
+ * Note: When returning to a byte read, remaining bits are dropped
2041
+ *
2042
+ * @param {boolean} unsigned - if the value is unsigned
2043
+ * @returns number
2044
+ */
2045
+ bit26be(unsigned) {
2046
+ return this.bit(26, unsigned, "big");
2047
+ }
2048
+ /**
2049
+ * Bit field reader
2050
+ *
2051
+ * Note: When returning to a byte read, remaining bits are dropped
2052
+ *
2053
+ * @returns number
2054
+ */
2055
+ ubit26() {
2056
+ return this.bit(26, true);
2057
+ }
2058
+ /**
2059
+ * Bit field reader
2060
+ *
2061
+ * Note: When returning to a byte read, remaining bits are dropped
2062
+ *
2063
+ * @returns number
2064
+ */
2065
+ ubit26le() {
2066
+ return this.bit(26, true, "little");
2067
+ }
2068
+ /**
2069
+ * Bit field reader
2070
+ *
2071
+ * Note: When returning to a byte read, remaining bits are dropped
2072
+ *
2073
+ * @returns number
2074
+ */
2075
+ ubit26be() {
2076
+ return this.bit(26, true, "big");
2077
+ }
2078
+ /**
2079
+ * Bit field reader
2080
+ *
2081
+ * Note: When returning to a byte read, remaining bits are dropped
2082
+ *
2083
+ * @param {boolean} unsigned - if the value is unsigned
2084
+ * @returns number
2085
+ */
2086
+ bit27(unsigned) {
2087
+ return this.bit(27, unsigned);
2088
+ }
2089
+ /**
2090
+ * Bit field reader
2091
+ *
2092
+ * Note: When returning to a byte read, remaining bits are dropped
2093
+ *
2094
+ * @param {boolean} unsigned - if the value is unsigned
2095
+ * @returns number
2096
+ */
2097
+ bit27le(unsigned) {
2098
+ return this.bit(27, unsigned, "little");
2099
+ }
2100
+ /**
2101
+ * Bit field reader
2102
+ *
2103
+ * Note: When returning to a byte read, remaining bits are dropped
2104
+ *
2105
+ * @param {boolean} unsigned - if the value is unsigned
2106
+ * @returns number
2107
+ */
2108
+ bit27be(unsigned) {
2109
+ return this.bit(27, unsigned, "big");
2110
+ }
2111
+ /**
2112
+ * Bit field reader
2113
+ *
2114
+ * Note: When returning to a byte read, remaining bits are dropped
2115
+ *
2116
+ * @returns number
2117
+ */
2118
+ ubit27() {
2119
+ return this.bit(27, true);
2120
+ }
2121
+ /**
2122
+ * Bit field reader
2123
+ *
2124
+ * Note: When returning to a byte read, remaining bits are dropped
2125
+ *
2126
+ * @returns number
2127
+ */
2128
+ ubit27le() {
2129
+ return this.bit(27, true, "little");
2130
+ }
2131
+ /**
2132
+ * Bit field reader
2133
+ *
2134
+ * Note: When returning to a byte read, remaining bits are dropped
2135
+ *
2136
+ * @returns number
2137
+ */
2138
+ ubit27be() {
2139
+ return this.bit(27, true, "big");
2140
+ }
2141
+ /**
2142
+ * Bit field reader
2143
+ *
2144
+ * Note: When returning to a byte read, remaining bits are dropped
2145
+ *
2146
+ * @param {boolean} unsigned - if the value is unsigned
2147
+ * @returns number
2148
+ */
2149
+ bit28(unsigned) {
2150
+ return this.bit(28, unsigned);
2151
+ }
2152
+ /**
2153
+ * Bit field reader
2154
+ *
2155
+ * Note: When returning to a byte read, remaining bits are dropped
2156
+ *
2157
+ * @param {boolean} unsigned - if the value is unsigned
2158
+ * @returns number
2159
+ */
2160
+ bit28le(unsigned) {
2161
+ return this.bit(28, unsigned, "little");
2162
+ }
2163
+ /**
2164
+ * Bit field reader
2165
+ *
2166
+ * Note: When returning to a byte read, remaining bits are dropped
2167
+ *
2168
+ * @param {boolean} unsigned - if the value is unsigned
2169
+ * @returns number
2170
+ */
2171
+ bit28be(unsigned) {
2172
+ return this.bit(28, unsigned, "big");
2173
+ }
2174
+ /**
2175
+ * Bit field reader
2176
+ *
2177
+ * Note: When returning to a byte read, remaining bits are dropped
2178
+ *
2179
+ * @returns number
2180
+ */
2181
+ ubit28() {
2182
+ return this.bit(28, true);
2183
+ }
2184
+ /**
2185
+ * Bit field reader
2186
+ *
2187
+ * Note: When returning to a byte read, remaining bits are dropped
2188
+ *
2189
+ * @returns number
2190
+ */
2191
+ ubit28le() {
2192
+ return this.bit(28, true, "little");
2193
+ }
2194
+ /**
2195
+ * Bit field reader
2196
+ *
2197
+ * Note: When returning to a byte read, remaining bits are dropped
2198
+ *
2199
+ * @returns number
2200
+ */
2201
+ ubit28be() {
2202
+ return this.bit(28, true, "big");
2203
+ }
2204
+ /**
2205
+ * Bit field reader
2206
+ *
2207
+ * Note: When returning to a byte read, remaining bits are dropped
2208
+ *
2209
+ * @param {boolean} unsigned - if the value is unsigned
2210
+ * @returns number
2211
+ */
2212
+ bit29(unsigned) {
2213
+ return this.bit(29, unsigned);
2214
+ }
2215
+ /**
2216
+ * Bit field reader
2217
+ *
2218
+ * Note: When returning to a byte read, remaining bits are dropped
2219
+ *
2220
+ * @param {boolean} unsigned - if the value is unsigned
2221
+ * @returns number
2222
+ */
2223
+ bit29le(unsigned) {
2224
+ return this.bit(29, unsigned, "little");
2225
+ }
2226
+ /**
2227
+ * Bit field reader
2228
+ *
2229
+ * Note: When returning to a byte read, remaining bits are dropped
2230
+ *
2231
+ * @param {boolean} unsigned - if the value is unsigned
2232
+ * @returns number
2233
+ */
2234
+ bit29be(unsigned) {
2235
+ return this.bit(29, unsigned, "big");
2236
+ }
2237
+ /**
2238
+ * Bit field reader
2239
+ *
2240
+ * Note: When returning to a byte read, remaining bits are dropped
2241
+ *
2242
+ * @returns number
2243
+ */
2244
+ ubit29() {
2245
+ return this.bit(29, true);
2246
+ }
2247
+ /**
2248
+ * Bit field reader
2249
+ *
2250
+ * Note: When returning to a byte read, remaining bits are dropped
2251
+ *
2252
+ * @returns number
2253
+ */
2254
+ ubit29le() {
2255
+ return this.bit(29, true, "little");
2256
+ }
2257
+ /**
2258
+ * Bit field reader
2259
+ *
2260
+ * Note: When returning to a byte read, remaining bits are dropped
2261
+ *
2262
+ * @returns number
2263
+ */
2264
+ ubit29be() {
2265
+ return this.bit(29, true, "big");
2266
+ }
2267
+ /**
2268
+ * Bit field reader
2269
+ *
2270
+ * Note: When returning to a byte read, remaining bits are dropped
2271
+ *
2272
+ * @param {boolean} unsigned - if the value is unsigned
2273
+ * @returns number
2274
+ */
2275
+ bit30(unsigned) {
2276
+ return this.bit(30, unsigned);
2277
+ }
2278
+ /**
2279
+ * Bit field reader
2280
+ *
2281
+ * Note: When returning to a byte read, remaining bits are dropped
2282
+ *
2283
+ * @param {boolean} unsigned - if the value is unsigned
2284
+ * @returns number
2285
+ */
2286
+ bit30le(unsigned) {
2287
+ return this.bit(30, unsigned, "little");
2288
+ }
2289
+ /**
2290
+ * Bit field reader
2291
+ *
2292
+ * Note: When returning to a byte read, remaining bits are dropped
2293
+ *
2294
+ * @param {boolean} unsigned - if the value is unsigned
2295
+ * @returns number
2296
+ */
2297
+ bit30be(unsigned) {
2298
+ return this.bit(30, unsigned, "big");
2299
+ }
2300
+ /**
2301
+ * Bit field reader
2302
+ *
2303
+ * Note: When returning to a byte read, remaining bits are dropped
2304
+ *
2305
+ * @returns number
2306
+ */
2307
+ ubit30() {
2308
+ return this.bit(30, true);
2309
+ }
2310
+ /**
2311
+ * Bit field reader
2312
+ *
2313
+ * Note: When returning to a byte read, remaining bits are dropped
2314
+ *
2315
+ * @returns number
2316
+ */
2317
+ ubit30le() {
2318
+ return this.bit(30, true, "little");
2319
+ }
2320
+ /**
2321
+ * Bit field reader
2322
+ *
2323
+ * Note: When returning to a byte read, remaining bits are dropped
2324
+ *
2325
+ * @returns number
2326
+ */
2327
+ ubit30be() {
2328
+ return this.bit(30, true, "big");
2329
+ }
2330
+ /**
2331
+ * Bit field reader
2332
+ *
2333
+ * Note: When returning to a byte read, remaining bits are dropped
2334
+ *
2335
+ * @param {boolean} unsigned - if the value is unsigned
2336
+ * @returns number
2337
+ */
2338
+ bit31(unsigned) {
2339
+ return this.bit(31, unsigned);
2340
+ }
2341
+ /**
2342
+ * Bit field reader
2343
+ *
2344
+ * Note: When returning to a byte read, remaining bits are dropped
2345
+ *
2346
+ * @param {boolean} unsigned - if the value is unsigned
2347
+ * @returns number
2348
+ */
2349
+ bit31le(unsigned) {
2350
+ return this.bit(31, unsigned, "little");
2351
+ }
2352
+ /**
2353
+ * Bit field reader
2354
+ *
2355
+ * Note: When returning to a byte read, remaining bits are dropped
2356
+ *
2357
+ * @param {boolean} unsigned - if the value is unsigned
2358
+ * @returns number
2359
+ */
2360
+ bit31be(unsigned) {
2361
+ return this.bit(31, unsigned, "big");
2362
+ }
2363
+ /**
2364
+ * Bit field reader
2365
+ *
2366
+ * Note: When returning to a byte read, remaining bits are dropped
2367
+ *
2368
+ * @returns number
2369
+ */
2370
+ ubit31() {
2371
+ return this.bit(31, true);
2372
+ }
2373
+ /**
2374
+ * Bit field reader
2375
+ *
2376
+ * Note: When returning to a byte read, remaining bits are dropped
2377
+ *
2378
+ * @returns number
2379
+ */
2380
+ ubit31le() {
2381
+ return this.bit(31, true, "little");
2382
+ }
2383
+ /**
2384
+ * Bit field reader
2385
+ *
2386
+ * Note: When returning to a byte read, remaining bits are dropped
2387
+ *
2388
+ * @returns number
2389
+ */
2390
+ ubit31be() {
2391
+ return this.bit(31, true, "big");
2392
+ }
2393
+ /**
2394
+ * Bit field reader
2395
+ *
2396
+ * Note: When returning to a byte read, remaining bits are dropped
2397
+ *
2398
+ * @param {boolean} unsigned - if the value is unsigned
2399
+ * @returns number
2400
+ */
2401
+ bit32(unsigned) {
2402
+ return this.bit(32, unsigned);
2403
+ }
2404
+ /**
2405
+ * Bit field reader
2406
+ *
2407
+ * Note: When returning to a byte read, remaining bits are dropped
2408
+ *
2409
+ * @param {boolean} unsigned - if the value is unsigned
2410
+ * @returns number
2411
+ */
2412
+ bit32le(unsigned) {
2413
+ return this.bit(32, unsigned, "little");
2414
+ }
2415
+ /**
2416
+ * Bit field reader
2417
+ *
2418
+ * Note: When returning to a byte read, remaining bits are dropped
2419
+ *
2420
+ * @param {boolean} unsigned - if the value is unsigned
2421
+ * @returns number
2422
+ */
2423
+ bit32be(unsigned) {
2424
+ return this.bit(32, unsigned, "big");
2425
+ }
2426
+ /**
2427
+ * Bit field reader
2428
+ *
2429
+ * Note: When returning to a byte read, remaining bits are dropped
2430
+ *
2431
+ * @returns number
2432
+ */
2433
+ ubit32() {
2434
+ return this.bit(32, true);
2435
+ }
2436
+ /**
2437
+ * Bit field reader
2438
+ *
2439
+ * Note: When returning to a byte read, remaining bits are dropped
2440
+ *
2441
+ * @returns number
2442
+ */
2443
+ ubit32le() {
2444
+ return this.bit(32, true, "little");
2445
+ }
2446
+ /**
2447
+ * Bit field reader
2448
+ *
2449
+ * Note: When returning to a byte read, remaining bits are dropped
2450
+ *
2451
+ * @returns number
2452
+ */
2453
+ ubit32be() {
2454
+ return this.bit(32, true, "big");
2455
+ }
2456
+ /**
2457
+ * Bit field reader
2458
+ *
2459
+ * Note: When returning to a byte read, remaining bits are dropped
2460
+ *
2461
+ * @param {number} bits - bits to read
2462
+ * @returns number
2463
+ */
2464
+ readUBitBE(bits) {
2465
+ return this.readBit(bits, true, "big");
2466
+ }
2467
+ /**
2468
+ * Bit field reader
2469
+ *
2470
+ * Note: When returning to a byte read, remaining bits are dropped
2471
+ *
2472
+ * @param {number} bits - bits to read
2473
+ * @returns number
2474
+ */
2475
+ ubitbe(bits) {
2476
+ return this.readBit(bits, true, "big");
2477
+ }
2478
+ /**
2479
+ * Bit field reader
2480
+ *
2481
+ * Note: When returning to a byte read, remaining bits are dropped
2482
+ *
2483
+ * @param {number} bits - bits to read
2484
+ * @param {boolean} unsigned - if the value is unsigned
2485
+ * @returns number
2486
+ */
2487
+ readBitBE(bits, unsigned) {
2488
+ return this.readBit(bits, unsigned, "big");
2489
+ }
2490
+ /**
2491
+ * Bit field reader
2492
+ *
2493
+ * Note: When returning to a byte read, remaining bits are dropped
2494
+ *
2495
+ * @param {number} bits - bits to read
2496
+ * @param {boolean} unsigned - if the value is unsigned
2497
+ * @returns number
2498
+ */
2499
+ bitbe(bits, unsigned) {
2500
+ return this.readBit(bits, unsigned, "big");
2501
+ }
2502
+ /**
2503
+ * Bit field reader
2504
+ *
2505
+ * Note: When returning to a byte read, remaining bits are dropped
2506
+ *
2507
+ * @param {number} bits - bits to read
2508
+ * @returns number
2509
+ */
2510
+ readUBitLE(bits) {
2511
+ return this.readBit(bits, true, "little");
2512
+ }
2513
+ /**
2514
+ * Bit field reader
2515
+ *
2516
+ * Note: When returning to a byte read, remaining bits are dropped
2517
+ *
2518
+ * @param {number} bits - bits to read
2519
+ * @returns number
2520
+ */
2521
+ ubitle(bits) {
2522
+ return this.readBit(bits, true, "little");
2523
+ }
2524
+ /**
2525
+ * Bit field reader
2526
+ *
2527
+ * Note: When returning to a byte read, remaining bits are dropped
2528
+ *
2529
+ * @param {number} bits - bits to read
2530
+ * @param {boolean} unsigned - if the value is unsigned
2531
+ * @returns number
2532
+ */
2533
+ readBitLE(bits, unsigned) {
2534
+ return this.readBit(bits, unsigned, "little");
2535
+ }
2536
+ /**
2537
+ * Bit field reader
2538
+ *
2539
+ * Note: When returning to a byte read, remaining bits are dropped
2540
+ *
2541
+ * @param {number} bits - bits to read
2542
+ * @param {boolean} unsigned - if the value is unsigned
2543
+ * @returns number
2544
+ */
2545
+ bitle(bits, unsigned) {
2546
+ return this.readBit(bits, unsigned, "little");
2547
+ }
2548
+ //
2549
+ //byte read
2550
+ //
2551
+ /**
2552
+ * Read byte
2553
+ *
2554
+ * @param {boolean} unsigned - if value is unsigned or not
2555
+ * @returns number
2556
+ */
2557
+ readByte(unsigned) {
2558
+ this.check_size(1);
2559
+ var read = this.data[this.offset];
2560
+ this.offset += 1;
2561
+ if (unsigned == true) {
2562
+ return read & 0xFF;
2563
+ }
2564
+ else {
2565
+ return read > 127 ? read - 256 : read;
2566
+ }
2567
+ }
2568
+ /**
2569
+ * Read byte
2570
+ *
2571
+ * @param {boolean} unsigned - if value is unsigned or not
2572
+ * @returns number
2573
+ */
2574
+ byte(unsigned) {
2575
+ return this.readByte(unsigned);
2576
+ }
2577
+ /**
2578
+ * Read byte
2579
+ *
2580
+ * @param {boolean} unsigned - if value is unsigned or not
2581
+ * @returns number
2582
+ */
2583
+ int8(unsigned) {
2584
+ return this.readByte(unsigned);
2585
+ }
2586
+ /**
2587
+ * Read unsigned byte
2588
+ *
2589
+ * @returns number
2590
+ */
2591
+ readUByte() {
2592
+ return this.readByte(true);
2593
+ }
2594
+ /**
2595
+ * Read unsigned byte
2596
+ *
2597
+ * @returns number
2598
+ */
2599
+ uint8() {
2600
+ return this.readByte(true);
2601
+ }
2602
+ /**
2603
+ * Read unsigned byte
2604
+ *
2605
+ * @returns number
2606
+ */
2607
+ ubyte() {
2608
+ return this.readByte(true);
2609
+ }
2610
+ //
2611
+ //short16 read
2612
+ //
2613
+ /**
2614
+ * Read short
2615
+ *
2616
+ * @param {boolean} unsigned - if value is unsigned or not
2617
+ * @param {string} endian - ```big``` or ```little```
2618
+ * @returns number
2619
+ */
2620
+ readInt16(unsigned, endian) {
2621
+ this.check_size(2);
2622
+ var read;
2623
+ if ((endian != undefined ? endian : this.endian) == "little") {
2624
+ read = (this.data[this.offset + 1] << 8) | this.data[this.offset];
2625
+ }
2626
+ else {
2627
+ read = (this.data[this.offset] << 8) | this.data[this.offset + 1];
2628
+ }
2629
+ this.offset += 2;
2630
+ if (unsigned == undefined || unsigned == false) {
2631
+ return read & 0x8000 ? -(0x10000 - read) : read;
2632
+ }
2633
+ else {
2634
+ return read & 0xFFFF;
2635
+ }
2636
+ }
2637
+ /**
2638
+ * Read short
2639
+ *
2640
+ * @param {boolean} unsigned - if value is unsigned or not
2641
+ * @param {string} endian - ```big``` or ```little```
2642
+ * @returns number
2643
+ */
2644
+ int16(unsigned, endian) {
2645
+ return this.readInt16(unsigned, endian);
2646
+ }
2647
+ /**
2648
+ * Read short
2649
+ *
2650
+ * @param {boolean} unsigned - if value is unsigned or not
2651
+ * @param {string} endian - ```big``` or ```little```
2652
+ * @returns number
2653
+ */
2654
+ short(unsigned, endian) {
2655
+ return this.readInt16(unsigned, endian);
2656
+ }
2657
+ /**
2658
+ * Read short
2659
+ *
2660
+ * @param {boolean} unsigned - if value is unsigned or not
2661
+ * @param {string} endian - ```big``` or ```little```
2662
+ * @returns number
2663
+ */
2664
+ word(unsigned, endian) {
2665
+ return this.readInt16(unsigned, endian);
2666
+ }
2667
+ /**
2668
+ * Read unsigned short
2669
+ *
2670
+ * @param {string} endian - ```big``` or ```little```
2671
+ *
2672
+ * @returns number
2673
+ */
2674
+ readUInt16(endian) {
2675
+ return this.readInt16(true, endian);
2676
+ }
2677
+ /**
2678
+ * Read unsigned short
2679
+ *
2680
+ * @param {string} endian - ```big``` or ```little```
2681
+ *
2682
+ * @returns number
2683
+ */
2684
+ uint16(endian) {
2685
+ return this.readInt16(true, endian);
2686
+ }
2687
+ /**
2688
+ * Read unsigned short
2689
+ *
2690
+ * @param {string} endian - ```big``` or ```little```
2691
+ *
2692
+ * @returns number
2693
+ */
2694
+ ushort(endian) {
2695
+ return this.readInt16(true, endian);
2696
+ }
2697
+ /**
2698
+ * Read unsigned short
2699
+ *
2700
+ * @param {string} endian - ```big``` or ```little```
2701
+ *
2702
+ * @returns number
2703
+ */
2704
+ uword(endian) {
2705
+ return this.readInt16(true, endian);
2706
+ }
2707
+ /**
2708
+ * Read unsigned short in little endian
2709
+ *
2710
+ * @returns number
2711
+ */
2712
+ readUInt16LE() {
2713
+ return this.readInt16(true, "little");
2714
+ }
2715
+ /**
2716
+ * Read unsigned short in little endian
2717
+ *
2718
+ * @returns number
2719
+ */
2720
+ uint16le() {
2721
+ return this.readInt16(true, "little");
2722
+ }
2723
+ /**
2724
+ * Read unsigned short in little endian
2725
+ *
2726
+ * @returns number
2727
+ */
2728
+ ushortle() {
2729
+ return this.readInt16(true, "little");
2730
+ }
2731
+ /**
2732
+ * Read unsigned short in little endian
2733
+ *
2734
+ * @returns number
2735
+ */
2736
+ uwordle() {
2737
+ return this.readInt16(true, "little");
2738
+ }
2739
+ /**
2740
+ * Read signed short in little endian
2741
+ *
2742
+ * @returns number
2743
+ */
2744
+ readInt16LE() {
2745
+ return this.readInt16(false, "little");
2746
+ }
2747
+ /**
2748
+ * Read signed short in little endian
2749
+ *
2750
+ * @returns number
2751
+ */
2752
+ int16le() {
2753
+ return this.readInt16(false, "little");
2754
+ }
2755
+ /**
2756
+ * Read signed short in little endian
2757
+ *
2758
+ * @returns number
2759
+ */
2760
+ shortle() {
2761
+ return this.readInt16(false, "little");
2762
+ }
2763
+ /**
2764
+ * Read signed short in little endian
2765
+ *
2766
+ * @returns number
2767
+ */
2768
+ wordle() {
2769
+ return this.readInt16(false, "little");
2770
+ }
2771
+ /**
2772
+ * Read unsigned short in big endian
2773
+ *
2774
+ * @returns number
2775
+ */
2776
+ readUInt16BE() {
2777
+ return this.readInt16(true, "big");
2778
+ }
2779
+ /**
2780
+ * Read unsigned short in big endian
2781
+ *
2782
+ * @returns number
2783
+ */
2784
+ uint16be() {
2785
+ return this.readInt16(true, "big");
2786
+ }
2787
+ /**
2788
+ * Read unsigned short in big endian
2789
+ *
2790
+ * @returns number
2791
+ */
2792
+ ushortbe() {
2793
+ return this.readInt16(true, "big");
2794
+ }
2795
+ /**
2796
+ * Read unsigned short in big endian
2797
+ *
2798
+ * @returns number
2799
+ */
2800
+ uwordbe() {
2801
+ return this.readInt16(true, "big");
2802
+ }
2803
+ /**
2804
+ * Read signed short in big endian
2805
+ *
2806
+ * @returns number
2807
+ */
2808
+ readInt16BE() {
2809
+ return this.readInt16(false, "big");
2810
+ }
2811
+ /**
2812
+ * Read signed short in big endian
2813
+ *
2814
+ * @returns number
2815
+ */
2816
+ int16be() {
2817
+ return this.readInt16(false, "big");
2818
+ }
2819
+ /**
2820
+ * Read signed short in big endian
2821
+ *
2822
+ * @returns number
2823
+ */
2824
+ shortbe() {
2825
+ return this.readInt16(false, "big");
2826
+ }
2827
+ /**
2828
+ * Read signed short in big endian
2829
+ *
2830
+ * @returns number
2831
+ */
2832
+ wordbe() {
2833
+ return this.readInt16(false, "big");
2834
+ }
2835
+ //
2836
+ //half float read
2837
+ //
2838
+ /**
2839
+ * Read half float
2840
+ *
2841
+ * @param {string} endian - ```big``` or ```little```
2842
+ * @returns number
2843
+ */
2844
+ readHalfFloat(endian) {
2845
+ this.check_size(2);
2846
+ var uint16Value = this.readInt16(true, (endian != undefined ? endian : this.endian));
2847
+ const sign = (uint16Value & 0x8000) >> 15;
2848
+ const exponent = (uint16Value & 0x7C00) >> 10;
2849
+ const fraction = uint16Value & 0x03FF;
2850
+ let floatValue;
2851
+ if (exponent === 0) {
2852
+ if (fraction === 0) {
2853
+ floatValue = (sign === 0) ? 0 : -0; // +/-0
2854
+ }
2855
+ else {
2856
+ // Denormalized number
2857
+ floatValue = (sign === 0 ? 1 : -1) * Math.pow(2, -14) * (fraction / 0x0400);
2858
+ }
2859
+ }
2860
+ else if (exponent === 0x1F) {
2861
+ if (fraction === 0) {
2862
+ floatValue = (sign === 0) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
2863
+ }
2864
+ else {
2865
+ floatValue = Number.NaN;
2866
+ }
2867
+ }
2868
+ else {
2869
+ // Normalized number
2870
+ floatValue = (sign === 0 ? 1 : -1) * Math.pow(2, exponent - 15) * (1 + fraction / 0x0400);
2871
+ }
2872
+ return floatValue;
2873
+ }
2874
+ /**
2875
+ * Read half float
2876
+ *
2877
+ * @param {string} endian - ```big``` or ```little```
2878
+ * @returns number
2879
+ */
2880
+ halffloat(endian) {
2881
+ return this.readHalfFloat(endian);
2882
+ }
2883
+ /**
2884
+ * Read half float
2885
+ *
2886
+ * @param {string} endian - ```big``` or ```little```
2887
+ * @returns number
2888
+ */
2889
+ half(endian) {
2890
+ return this.readHalfFloat(endian);
2891
+ }
2892
+ /**
2893
+ * Read half float
2894
+ *
2895
+ * @returns number
2896
+ */
2897
+ readHalfFloatBE() {
2898
+ return this.readHalfFloat("big");
2899
+ }
2900
+ /**
2901
+ * Read half float
2902
+ *
2903
+ * @returns number
2904
+ */
2905
+ halffloatbe() {
2906
+ return this.readHalfFloat("big");
2907
+ }
2908
+ /**
2909
+ * Read half float
2910
+ *
2911
+ * @returns number
2912
+ */
2913
+ halfbe() {
2914
+ return this.readHalfFloat("big");
2915
+ }
2916
+ /**
2917
+ * Read half float
2918
+ *
2919
+ * @returns number
2920
+ */
2921
+ readHalfFloatLE() {
2922
+ return this.readHalfFloat("little");
2923
+ }
2924
+ /**
2925
+ * Read half float
2926
+ *
2927
+ * @returns number
2928
+ */
2929
+ halffloatle() {
2930
+ return this.readHalfFloat("little");
2931
+ }
2932
+ /**
2933
+ * Read half float
2934
+ *
2935
+ * @returns number
2936
+ */
2937
+ halfle() {
2938
+ return this.readHalfFloat("little");
2939
+ }
2940
+ //
2941
+ //int read
2942
+ //
2943
+ /**
2944
+ * Read 32 bit integer
2945
+ *
2946
+ * @param {boolean} unsigned - if value is unsigned or not
2947
+ * @param {string} endian - ```big``` or ```little```
2948
+ * @returns number
2949
+ */
2950
+ readInt32(unsigned, endian) {
2951
+ this.check_size(4);
2952
+ var read;
2953
+ if ((endian != undefined ? endian : this.endian) == "little") {
2954
+ read = ((this.data[this.offset + 3] << 24) | (this.data[this.offset + 2] << 16) | (this.data[this.offset + 1] << 8) | this.data[this.offset]);
2955
+ }
2956
+ else {
2957
+ read = (this.data[this.offset] << 24) | (this.data[this.offset + 1] << 16) | (this.data[this.offset + 2] << 8) | this.data[this.offset + 3];
2958
+ }
2959
+ this.offset += 4;
2960
+ if (unsigned == undefined || unsigned == false) {
2961
+ return read;
2962
+ }
2963
+ else {
2964
+ return read >>> 0;
2965
+ }
2966
+ }
2967
+ /**
2968
+ * Read 32 bit integer
2969
+ *
2970
+ * @param {boolean} unsigned - if value is unsigned or not
2971
+ * @param {string} endian - ```big``` or ```little```
2972
+ * @returns number
2973
+ */
2974
+ int(unsigned, endian) {
2975
+ return this.readInt32(unsigned, endian);
2976
+ }
2977
+ /**
2978
+ * Read 32 bit integer
2979
+ *
2980
+ * @param {boolean} unsigned - if value is unsigned or not
2981
+ * @param {string} endian - ```big``` or ```little```
2982
+ * @returns number
2983
+ */
2984
+ double(unsigned, endian) {
2985
+ return this.readInt32(unsigned, endian);
2986
+ }
2987
+ /**
2988
+ * Read 32 bit integer
2989
+ *
2990
+ * @param {boolean} unsigned - if value is unsigned or not
2991
+ * @param {string} endian - ```big``` or ```little```
2992
+ * @returns number
2993
+ */
2994
+ int32(unsigned, endian) {
2995
+ return this.readInt32(unsigned, endian);
2996
+ }
2997
+ /**
2998
+ * Read 32 bit integer
2999
+ *
3000
+ * @param {boolean} unsigned - if value is unsigned or not
3001
+ * @param {string} endian - ```big``` or ```little```
3002
+ * @returns number
3003
+ */
3004
+ long(unsigned, endian) {
3005
+ return this.readInt32(unsigned, endian);
3006
+ }
3007
+ /**
3008
+ * Read unsigned 32 bit integer
3009
+ *
3010
+ * @returns number
3011
+ */
3012
+ readUInt() {
3013
+ return this.readInt32(true);
3014
+ }
3015
+ /**
3016
+ * Read unsigned 32 bit integer
3017
+ *
3018
+ * @returns number
3019
+ */
3020
+ uint() {
3021
+ return this.readInt32(true);
3022
+ }
3023
+ /**
3024
+ * Read unsigned 32 bit integer
3025
+ *
3026
+ * @returns number
3027
+ */
3028
+ udouble() {
3029
+ return this.readInt32(true);
3030
+ }
3031
+ /**
3032
+ * Read unsigned 32 bit integer
3033
+ *
3034
+ * @returns number
3035
+ */
3036
+ uint32() {
3037
+ return this.readInt32(true);
3038
+ }
3039
+ /**
3040
+ * Read unsigned 32 bit integer
3041
+ *
3042
+ * @returns number
3043
+ */
3044
+ ulong() {
3045
+ return this.readInt32(true);
3046
+ }
3047
+ /**
3048
+ * Read signed 32 bit integer
3049
+ *
3050
+ * @returns number
3051
+ */
3052
+ readInt32BE() {
3053
+ return this.readInt32(false, "big");
3054
+ }
3055
+ /**
3056
+ * Read signed 32 bit integer
3057
+ *
3058
+ * @returns number
3059
+ */
3060
+ intbe() {
3061
+ return this.readInt32(false, "big");
3062
+ }
3063
+ /**
3064
+ * Read signed 32 bit integer
3065
+ *
3066
+ * @returns number
3067
+ */
3068
+ doublebe() {
3069
+ return this.readInt32(false, "big");
3070
+ }
3071
+ /**
3072
+ * Read signed 32 bit integer
3073
+ *
3074
+ * @returns number
3075
+ */
3076
+ int32be() {
3077
+ return this.readInt32(false, "big");
3078
+ }
3079
+ /**
3080
+ * Read signed 32 bit integer
3081
+ *
3082
+ * @returns number
3083
+ */
3084
+ longbe() {
3085
+ return this.readInt32(false, "big");
3086
+ }
3087
+ /**
3088
+ * Read unsigned 32 bit integer
3089
+ *
3090
+ * @returns number
3091
+ */
3092
+ readUInt32BE() {
3093
+ return this.readInt32(true, "big");
3094
+ }
3095
+ /**
3096
+ * Read unsigned 32 bit integer
3097
+ *
3098
+ * @returns number
3099
+ */
3100
+ uintbe() {
3101
+ return this.readInt32(true, "big");
3102
+ }
3103
+ /**
3104
+ * Read unsigned 32 bit integer
3105
+ *
3106
+ * @returns number
3107
+ */
3108
+ udoublebe() {
3109
+ return this.readInt32(true, "big");
3110
+ }
3111
+ /**
3112
+ * Read unsigned 32 bit integer
3113
+ *
3114
+ * @returns number
3115
+ */
3116
+ uint32be() {
3117
+ return this.readInt32(true, "big");
3118
+ }
3119
+ /**
3120
+ * Read unsigned 32 bit integer
3121
+ *
3122
+ * @returns number
3123
+ */
3124
+ ulongbe() {
3125
+ return this.readInt32(true, "big");
3126
+ }
3127
+ /**
3128
+ * Read signed 32 bit integer
3129
+ *
3130
+ * @returns number
3131
+ */
3132
+ readInt32LE() {
3133
+ return this.readInt32(false, "little");
3134
+ }
3135
+ /**
3136
+ * Read signed 32 bit integer
3137
+ *
3138
+ * @returns number
3139
+ */
3140
+ intle() {
3141
+ return this.readInt32(false, "little");
3142
+ }
3143
+ /**
3144
+ * Read signed 32 bit integer
3145
+ *
3146
+ * @returns number
3147
+ */
3148
+ doublele() {
3149
+ return this.readInt32(false, "little");
3150
+ }
3151
+ /**
3152
+ * Read signed 32 bit integer
3153
+ *
3154
+ * @returns number
3155
+ */
3156
+ int32le() {
3157
+ return this.readInt32(false, "little");
3158
+ }
3159
+ /**
3160
+ * Read signed 32 bit integer
3161
+ *
3162
+ * @returns number
3163
+ */
3164
+ longle() {
3165
+ return this.readInt32(false, "little");
3166
+ }
3167
+ /**
3168
+ * Read signed 32 bit integer
3169
+ *
3170
+ * @returns number
3171
+ */
3172
+ readUInt32LE() {
3173
+ return this.readInt32(true, "little");
3174
+ }
3175
+ /**
3176
+ * Read signed 32 bit integer
3177
+ *
3178
+ * @returns number
3179
+ */
3180
+ uintle() {
3181
+ return this.readInt32(true, "little");
3182
+ }
3183
+ /**
3184
+ * Read signed 32 bit integer
3185
+ *
3186
+ * @returns number
3187
+ */
3188
+ udoublele() {
3189
+ return this.readInt32(true, "little");
3190
+ }
3191
+ /**
3192
+ * Read signed 32 bit integer
3193
+ *
3194
+ * @returns number
3195
+ */
3196
+ uint32le() {
3197
+ return this.readInt32(true, "little");
3198
+ }
3199
+ /**
3200
+ * Read signed 32 bit integer
3201
+ *
3202
+ * @returns number
3203
+ */
3204
+ ulongle() {
3205
+ return this.readInt32(true, "little");
3206
+ }
3207
+ //
3208
+ //float read
3209
+ //
3210
+ /**
3211
+ * Read float
3212
+ *
3213
+ * @param {string} endian - ```big``` or ```little```
3214
+ * @returns number
3215
+ */
3216
+ readFloat(endian) {
3217
+ this.check_size(4);
3218
+ var uint32Value = this.readInt32(true, (endian == undefined ? this.endian : endian));
3219
+ // Check if the value is negative (i.e., the most significant bit is set)
3220
+ const isNegative = (uint32Value & 0x80000000) !== 0 ? 1 : 0;
3221
+ // Extract the exponent and fraction parts
3222
+ const exponent = (uint32Value >> 23) & 0xFF;
3223
+ const fraction = uint32Value & 0x7FFFFF;
3224
+ // Calculate the float value
3225
+ let floatValue;
3226
+ if (exponent === 0) {
3227
+ // Denormalized number (exponent is 0)
3228
+ floatValue = Math.pow(-1, isNegative) * Math.pow(2, -126) * (fraction / Math.pow(2, 23));
3229
+ }
3230
+ else if (exponent === 0xFF) {
3231
+ // Infinity or NaN (exponent is 255)
3232
+ floatValue = fraction === 0 ? (isNegative ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY) : Number.NaN;
3233
+ }
3234
+ else {
3235
+ // Normalized number
3236
+ floatValue = Math.pow(-1, isNegative) * Math.pow(2, exponent - 127) * (1 + fraction / Math.pow(2, 23));
3237
+ }
3238
+ return floatValue;
3239
+ }
3240
+ /**
3241
+ * Read float
3242
+ *
3243
+ * @param {string} endian - ```big``` or ```little```
3244
+ * @returns number
3245
+ */
3246
+ float(endian) {
3247
+ return this.readFloat(endian);
3248
+ }
3249
+ /**
3250
+ * Read float
3251
+ *
3252
+ * @returns number
3253
+ */
3254
+ readFloatBE() {
3255
+ return this.readFloat("big");
3256
+ }
3257
+ /**
3258
+ * Read float
3259
+ *
3260
+ * @returns number
3261
+ */
3262
+ floatbe() {
3263
+ return this.readFloat("big");
3264
+ }
3265
+ /**
3266
+ * Read float
3267
+ *
3268
+ * @returns number
3269
+ */
3270
+ readFloatLE() {
3271
+ return this.readFloat("little");
3272
+ }
3273
+ /**
3274
+ * Read float
3275
+ *
3276
+ * @returns number
3277
+ */
3278
+ floatle() {
3279
+ return this.readFloat("little");
3280
+ }
3281
+ //
3282
+ //int64 reader
3283
+ //
3284
+ /**
3285
+ * Read signed 64 bit integer
3286
+ * @param {boolean} unsigned - if value is unsigned or not
3287
+ * @param {string} endian - ```big``` or ```little```
3288
+ * @returns number
3289
+ */
3290
+ readInt64(unsigned, endian) {
3291
+ this.check_size(8);
3292
+ // Convert the byte array to a BigInt
3293
+ let value = BigInt(0);
3294
+ if ((endian == undefined ? this.endian : endian) == "little") {
3295
+ for (let i = 0; i < 8; i++) {
3296
+ value = value | BigInt(this.data[this.offset]) << BigInt(8 * i);
3297
+ this.offset += 1;
3298
+ }
3299
+ if (unsigned == undefined || unsigned == false) {
3300
+ if (value & (BigInt(1) << BigInt(63))) {
3301
+ value -= BigInt(1) << BigInt(64);
3302
+ }
3303
+ return value;
3304
+ }
3305
+ else {
3306
+ return value;
3307
+ }
3308
+ }
3309
+ else {
3310
+ for (let i = 0; i < 8; i++) {
3311
+ value = (value << BigInt(8)) | BigInt(this.data[this.offset]);
3312
+ this.offset += 1;
3313
+ }
3314
+ if (unsigned == undefined || unsigned == false) {
3315
+ if (value & (BigInt(1) << BigInt(63))) {
3316
+ value -= BigInt(1) << BigInt(64);
3317
+ }
3318
+ return value;
3319
+ }
3320
+ else {
3321
+ return value;
3322
+ }
3323
+ }
3324
+ }
3325
+ /**
3326
+ * Read signed 64 bit integer
3327
+ * @param {boolean} unsigned - if value is unsigned or not
3328
+ * @param {string} endian - ```big``` or ```little```
3329
+ * @returns number
3330
+ */
3331
+ int64(unsigned, endian) {
3332
+ return this.readInt64(unsigned, endian);
3333
+ }
3334
+ /**
3335
+ * Read signed 64 bit integer
3336
+ * @param {boolean} unsigned - if value is unsigned or not
3337
+ * @param {string} endian - ```big``` or ```little```
3338
+ * @returns number
3339
+ */
3340
+ bigint(unsigned, endian) {
3341
+ return this.readInt64(unsigned, endian);
3342
+ }
3343
+ /**
3344
+ * Read signed 64 bit integer
3345
+ * @param {boolean} unsigned - if value is unsigned or not
3346
+ * @param {string} endian - ```big``` or ```little```
3347
+ * @returns number
3348
+ */
3349
+ quad(unsigned, endian) {
3350
+ return this.readInt64(unsigned, endian);
3351
+ }
3352
+ /**
3353
+ * Read unsigned 64 bit integer
3354
+ *
3355
+ * @returns number
3356
+ */
3357
+ readUInt64() {
3358
+ return this.readInt64(true);
3359
+ }
3360
+ /**
3361
+ * Read unsigned 64 bit integer
3362
+ *
3363
+ * @returns number
3364
+ */
3365
+ uint64() {
3366
+ return this.readInt64(true);
3367
+ }
3368
+ /**
3369
+ * Read unsigned 64 bit integer
3370
+ *
3371
+ * @returns number
3372
+ */
3373
+ ubigint() {
3374
+ return this.readInt64(true);
3375
+ }
3376
+ /**
3377
+ * Read unsigned 64 bit integer
3378
+ *
3379
+ * @returns number
3380
+ */
3381
+ uquad() {
3382
+ return this.readInt64(true);
3383
+ }
3384
+ /**
3385
+ * Read signed 64 bit integer
3386
+ *
3387
+ * @returns number
3388
+ */
3389
+ readInt64BE() {
3390
+ return this.readInt64(false, "big");
3391
+ }
3392
+ /**
3393
+ * Read signed 64 bit integer
3394
+ *
3395
+ * @returns number
3396
+ */
3397
+ int64be() {
3398
+ return this.readInt64(false, "big");
3399
+ }
3400
+ /**
3401
+ * Read signed 64 bit integer
3402
+ *
3403
+ * @returns number
3404
+ */
3405
+ bigintbe() {
3406
+ return this.readInt64(false, "big");
3407
+ }
3408
+ /**
3409
+ * Read signed 64 bit integer
3410
+ *
3411
+ * @returns number
3412
+ */
3413
+ quadbe() {
3414
+ return this.readInt64(false, "big");
3415
+ }
3416
+ /**
3417
+ * Read unsigned 64 bit integer
3418
+ *
3419
+ * @returns number
3420
+ */
3421
+ readUInt64BE() {
3422
+ return this.readInt64(true, "big");
3423
+ }
3424
+ /**
3425
+ * Read unsigned 64 bit integer
3426
+ *
3427
+ * @returns number
3428
+ */
3429
+ uint64be() {
3430
+ return this.readInt64(true, "big");
3431
+ }
3432
+ /**
3433
+ * Read unsigned 64 bit integer
3434
+ *
3435
+ * @returns number
3436
+ */
3437
+ ubigintbe() {
3438
+ return this.readInt64(true, "big");
3439
+ }
3440
+ /**
3441
+ * Read unsigned 64 bit integer
3442
+ *
3443
+ * @returns number
3444
+ */
3445
+ uquadbe() {
3446
+ return this.readInt64(true, "big");
3447
+ }
3448
+ /**
3449
+ * Read signed 64 bit integer
3450
+ *
3451
+ * @returns number
3452
+ */
3453
+ readInt64LE() {
3454
+ return this.readInt64(false, "little");
3455
+ }
3456
+ /**
3457
+ * Read signed 64 bit integer
3458
+ *
3459
+ * @returns number
3460
+ */
3461
+ int64le() {
3462
+ return this.readInt64(false, "little");
3463
+ }
3464
+ /**
3465
+ * Read signed 64 bit integer
3466
+ *
3467
+ * @returns number
3468
+ */
3469
+ bigintle() {
3470
+ return this.readInt64(false, "little");
3471
+ }
3472
+ /**
3473
+ * Read signed 64 bit integer
3474
+ *
3475
+ * @returns number
3476
+ */
3477
+ quadle() {
3478
+ return this.readInt64(false, "little");
3479
+ }
3480
+ /**
3481
+ * Read unsigned 64 bit integer
3482
+ *
3483
+ * @returns number
3484
+ */
3485
+ readUInt64LE() {
3486
+ return this.readInt64(true, "little");
3487
+ }
3488
+ /**
3489
+ * Read unsigned 64 bit integer
3490
+ *
3491
+ * @returns number
3492
+ */
3493
+ uint64le() {
3494
+ return this.readInt64(true, "little");
3495
+ }
3496
+ /**
3497
+ * Read unsigned 64 bit integer
3498
+ *
3499
+ * @returns number
3500
+ */
3501
+ ubigintle() {
3502
+ return this.readInt64(true, "little");
3503
+ }
3504
+ /**
3505
+ * Read unsigned 64 bit integer
3506
+ *
3507
+ * @returns number
3508
+ */
3509
+ uquadle() {
3510
+ return this.readInt64(true, "little");
3511
+ }
3512
+ //
3513
+ //doublefloat reader
3514
+ //
3515
+ /**
3516
+ * Read double float
3517
+ *
3518
+ * @param {string} endian - ```big``` or ```little```
3519
+ * @returns number
3520
+ */
3521
+ readDoubleFloat(endian) {
3522
+ this.check_size(8);
3523
+ var uint64Value = this.readInt64(true, (endian == undefined ? this.endian : endian));
3524
+ const sign = (uint64Value & 0x8000000000000000n) >> 63n;
3525
+ const exponent = Number((uint64Value & 0x7ff0000000000000n) >> 52n) - 1023;
3526
+ const fraction = Number(uint64Value & 0x000fffffffffffffn) / Math.pow(2, 52);
3527
+ var floatValue;
3528
+ if (exponent == -1023) {
3529
+ if (fraction == 0) {
3530
+ floatValue = (sign == 0n) ? 0 : -0; // +/-0
3531
+ }
3532
+ else {
3533
+ // Denormalized number
3534
+ floatValue = (sign == 0n ? 1 : -1) * Math.pow(2, -1022) * fraction;
3535
+ }
3536
+ }
3537
+ else if (exponent == 1024) {
3538
+ if (fraction == 0) {
3539
+ floatValue = (sign == 0n) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
3540
+ }
3541
+ else {
3542
+ floatValue = Number.NaN;
3543
+ }
3544
+ }
3545
+ else {
3546
+ // Normalized number
3547
+ floatValue = (sign == 0n ? 1 : -1) * Math.pow(2, exponent) * (1 + fraction);
3548
+ }
3549
+ return floatValue;
3550
+ }
3551
+ /**
3552
+ * Read double float
3553
+ *
3554
+ * @param {string} endian - ```big``` or ```little```
3555
+ * @returns number
3556
+ */
3557
+ doublefloat(endian) {
3558
+ return this.readDoubleFloat(endian);
3559
+ }
3560
+ /**
3561
+ * Read double float
3562
+ *
3563
+ * @param {string} endian - ```big``` or ```little```
3564
+ * @returns number
3565
+ */
3566
+ dfloat(endian) {
3567
+ return this.readDoubleFloat(endian);
3568
+ }
3569
+ /**
3570
+ * Read double float
3571
+ *
3572
+ * @returns number
3573
+ */
3574
+ readDoubleFloatBE() {
3575
+ return this.readDoubleFloat("big");
3576
+ }
3577
+ /**
3578
+ * Read double float
3579
+ *
3580
+ * @returns number
3581
+ */
3582
+ dfloatebe() {
3583
+ return this.readDoubleFloat("big");
3584
+ }
3585
+ /**
3586
+ * Read double float
3587
+ *
3588
+ * @returns number
3589
+ */
3590
+ doublefloatbe() {
3591
+ return this.readDoubleFloat("big");
3592
+ }
3593
+ /**
3594
+ * Read double float
3595
+ *
3596
+ * @returns number
3597
+ */
3598
+ readDoubleFloatLE() {
3599
+ return this.readDoubleFloat("little");
3600
+ }
3601
+ /**
3602
+ * Read double float
3603
+ *
3604
+ * @returns number
3605
+ */
3606
+ dfloatle() {
3607
+ return this.readDoubleFloat("little");
3608
+ }
3609
+ /**
3610
+ * Read double float
3611
+ *
3612
+ * @returns number
3613
+ */
3614
+ doublefloatle() {
3615
+ return this.readDoubleFloat("little");
3616
+ }
3617
+ //
3618
+ //string reader
3619
+ //
3620
+ /**
3621
+ * Reads string, use options object for different types
3622
+ *
3623
+ * @param {object} options
3624
+ * ```javascript
3625
+ * {
3626
+ * length: number, //for fixed length, non-terminate value utf strings
3627
+ * stringType: "utf-8", //utf-8, utf-16, pascal or wide-pascal
3628
+ * terminateValue: 0x00, // only for non-fixed length utf strings
3629
+ * lengthReadSize: 1, //for pascal strings. 1, 2 or 4 byte length read size
3630
+ * stripNull: true, // removes 0x00 characters
3631
+ * encoding: "utf-8", //TextEncoder accepted types
3632
+ * endian: "little", //for wide-pascal and utf-16
3633
+ * }
3634
+ * ```
3635
+ * @return string
3636
+ */
3637
+ readString(options) {
3638
+ var length = options && options.length;
3639
+ var stringType = options && options.stringType || 'utf-8';
3640
+ var terminateValue = options && options.terminateValue;
3641
+ var lengthReadSize = options && options.lengthReadSize || 1;
3642
+ var stripNull = options && options.stripNull || true;
3643
+ var encoding = options && options.encoding || 'utf-8';
3644
+ var endian = options && options.endian || this.endian;
3645
+ var terminate = terminateValue;
3646
+ if (length != undefined) {
3647
+ this.check_size(length);
3648
+ }
3649
+ if (typeof terminateValue == "number") {
3650
+ terminate = terminateValue & 0xFF;
3651
+ }
3652
+ else {
3653
+ if (terminateValue != undefined) {
3654
+ throw new Error("terminateValue must be a number");
3655
+ }
3656
+ }
3657
+ if (stringType == 'utf-8' || stringType == 'utf-16') {
3658
+ if (encoding == undefined) {
3659
+ if (stringType == 'utf-8') {
3660
+ encoding = 'utf-8';
3661
+ }
3662
+ if (stringType == 'utf-16') {
3663
+ encoding = 'utf-16';
3664
+ }
3665
+ }
3666
+ // Read the string as UTF-8 encoded untill 0 or terminateValue
3667
+ const encodedBytes = [];
3668
+ if (length == undefined && terminateValue == undefined) {
3669
+ terminate = 0;
3670
+ }
3671
+ var read_length = 0;
3672
+ if (length != undefined) {
3673
+ read_length = length;
3674
+ }
3675
+ else {
3676
+ read_length = this.data.length - this.offset;
3677
+ }
3678
+ for (let i = 0; i < read_length; i++) {
3679
+ if (stringType === 'utf-8') {
3680
+ var read = this.readUByte();
3681
+ if (read == terminate) {
3682
+ break;
3683
+ }
3684
+ else {
3685
+ if (!(stripNull == true && read == 0)) {
3686
+ encodedBytes.push(read);
3687
+ }
3688
+ }
3689
+ }
3690
+ else {
3691
+ var read = this.readInt16(true, endian);
3692
+ var read1 = read & 0xFF;
3693
+ var read2 = (read >> 8) & 0xFF;
3694
+ if (read == terminate) {
3695
+ break;
3696
+ }
3697
+ else {
3698
+ if (!(stripNull == true && read == 0)) {
3699
+ encodedBytes.push(read1);
3700
+ encodedBytes.push(read2);
3701
+ }
3702
+ }
3703
+ }
3704
+ }
3705
+ return new TextDecoder(encoding).decode(new Uint8Array(encodedBytes));
3706
+ }
3707
+ else if (stringType == 'pascal' || stringType == 'wide-pascal') {
3708
+ if (encoding == undefined) {
3709
+ if (stringType == 'pascal') {
3710
+ encoding = 'utf-8';
3711
+ }
3712
+ if (stringType == 'wide-pascal') {
3713
+ encoding = 'utf-16';
3714
+ }
3715
+ }
3716
+ var maxBytes;
3717
+ if (lengthReadSize == 1) {
3718
+ maxBytes = this.readUByte();
3719
+ }
3720
+ else if (lengthReadSize == 2) {
3721
+ maxBytes = this.readInt16(true, endian);
3722
+ }
3723
+ else if (lengthReadSize == 4) {
3724
+ maxBytes = this.readInt32(true, endian);
3725
+ }
3726
+ else {
3727
+ throw new Error("Invalid length read size: " + lengthReadSize);
3728
+ }
3729
+ // Read the string as Pascal or Delphi encoded
3730
+ const encodedBytes = [];
3731
+ for (let i = 0; i < maxBytes; i++) {
3732
+ if (stringType == 'wide-pascal') {
3733
+ const read = this.readInt16(true, endian);
3734
+ if (!(stripNull == true && read == 0)) {
3735
+ encodedBytes.push(read);
3736
+ }
3737
+ }
3738
+ else {
3739
+ const read = this.readUByte();
3740
+ if (!(stripNull == true && read == 0)) {
3741
+ encodedBytes.push(read);
3742
+ }
3743
+ }
3744
+ }
3745
+ var str_return;
3746
+ if (stringType == 'wide-pascal') {
3747
+ str_return = new TextDecoder(encoding).decode(new Uint16Array(encodedBytes));
3748
+ }
3749
+ else {
3750
+ str_return = new TextDecoder(encoding).decode(new Uint8Array(encodedBytes));
3751
+ }
3752
+ return str_return;
3753
+ }
3754
+ else {
3755
+ throw new Error('Unsupported string type: ' + stringType);
3756
+ }
3757
+ }
3758
+ string(options) {
3759
+ return this.readString(options);
3760
+ }
3761
+ /**
3762
+ * Reads UTF-8 (C) string
3763
+ *
3764
+ * @param {number} length - for fixed length utf strings
3765
+ * @param {number} terminateValue - for non-fixed length utf strings
3766
+ * @param {boolean} stripNull - removes 0x00 characters
3767
+ *
3768
+ * @return string
3769
+ */
3770
+ utf8string(length, terminateValue, stripNull) {
3771
+ return this.string({ stringType: "utf-8", encoding: "utf-8", length: length, terminateValue: terminateValue, stripNull: stripNull });
3772
+ }
3773
+ /**
3774
+ * Reads UTF-8 (C) string
3775
+ *
3776
+ * @param {number} length - for fixed length utf strings
3777
+ * @param {number} terminateValue - for non-fixed length utf strings
3778
+ * @param {boolean} stripNull - removes 0x00 characters
3779
+ *
3780
+ * @return string
3781
+ */
3782
+ cstring(length, terminateValue, stripNull) {
3783
+ return this.string({ stringType: "utf-8", encoding: "utf-8", length: length, terminateValue: terminateValue, stripNull: stripNull });
3784
+ }
3785
+ /**
3786
+ * Reads ANSI string
3787
+ *
3788
+ * @param {number} length - for fixed length utf strings
3789
+ * @param {number} terminateValue - for non-fixed length utf strings
3790
+ * @param {boolean} stripNull - removes 0x00 characters
3791
+ *
3792
+ * @return string
3793
+ */
3794
+ ansistring(length, terminateValue, stripNull) {
3795
+ return this.string({ stringType: "utf-8", encoding: "windows-1252", length: length, terminateValue: terminateValue, stripNull: stripNull });
3796
+ }
3797
+ /**
3798
+ * Reads UTF-16 (Unicode) string
3799
+ *
3800
+ * @param {number} length - for fixed length utf strings
3801
+ * @param {number} terminateValue - for non-fixed length utf strings
3802
+ * @param {boolean} stripNull - removes 0x00 characters
3803
+ * @param {string} endian - ``big`` or ``little``
3804
+ *
3805
+ * @return string
3806
+ */
3807
+ utf16string(length, terminateValue, stripNull, endian) {
3808
+ return this.string({ stringType: "utf-16", encoding: "utf-16", length: length, terminateValue: terminateValue, endian: endian, stripNull: stripNull });
3809
+ }
3810
+ /**
3811
+ * Reads UTF-16 (Unicode) string
3812
+ *
3813
+ * @param {number} length - for fixed length utf strings
3814
+ * @param {number} terminateValue - for non-fixed length utf strings
3815
+ * @param {boolean} stripNull - removes 0x00 characters
3816
+ * @param {string} endian - ``big`` or ``little``
3817
+ *
3818
+ * @return string
3819
+ */
3820
+ unistring(length, terminateValue, stripNull, endian) {
3821
+ return this.string({ stringType: "utf-16", encoding: "utf-16", length: length, terminateValue: terminateValue, endian: endian, stripNull: stripNull });
3822
+ }
3823
+ /**
3824
+ * Reads UTF-16 (Unicode) string in little endian order
3825
+ *
3826
+ * @param {number} length - for fixed length utf strings
3827
+ * @param {number} terminateValue - for non-fixed length utf strings
3828
+ * @param {boolean} stripNull - removes 0x00 characters
3829
+ *
3830
+ * @return string
3831
+ */
3832
+ utf16stringle(length, terminateValue, stripNull) {
3833
+ return this.string({ stringType: "utf-16", encoding: "utf-16", length: length, terminateValue: terminateValue, endian: "little", stripNull: stripNull });
3834
+ }
3835
+ /**
3836
+ * Reads UTF-16 (Unicode) string in little endian order
3837
+ *
3838
+ * @param {number} length - for fixed length utf strings
3839
+ * @param {number} terminateValue - for non-fixed length utf strings
3840
+ * @param {boolean} stripNull - removes 0x00 characters
3841
+ *
3842
+ * @return string
3843
+ */
3844
+ unistringle(length, terminateValue, stripNull) {
3845
+ return this.string({ stringType: "utf-16", encoding: "utf-16", length: length, terminateValue: terminateValue, endian: "little", stripNull: stripNull });
3846
+ }
3847
+ /**
3848
+ * Reads UTF-16 (Unicode) string in big endian order
3849
+ *
3850
+ * @param {number} length - for fixed length utf strings
3851
+ * @param {number} terminateValue - for non-fixed length utf strings
3852
+ * @param {boolean} stripNull - removes 0x00 characters
3853
+ *
3854
+ * @return string
3855
+ */
3856
+ utf16stringbe(length, terminateValue, stripNull) {
3857
+ return this.string({ stringType: "utf-16", encoding: "utf-16", length: length, terminateValue: terminateValue, endian: "big", stripNull: stripNull });
3858
+ }
3859
+ /**
3860
+ * Reads UTF-16 (Unicode) string in big endian order
3861
+ *
3862
+ * @param {number} length - for fixed length utf strings
3863
+ * @param {number} terminateValue - for non-fixed length utf strings
3864
+ * @param {boolean} stripNull - removes 0x00 characters
3865
+ *
3866
+ * @return string
3867
+ */
3868
+ unistringbe(length, terminateValue, stripNull) {
3869
+ return this.string({ stringType: "utf-16", encoding: "utf-16", length: length, terminateValue: terminateValue, endian: "big", stripNull: stripNull });
3870
+ }
3871
+ /**
3872
+ * Reads Pascal string
3873
+ *
3874
+ * @param {number} lengthReadSize - 1, 2 or 4 byte length write size (default 1)
3875
+ * @param {boolean} stripNull - removes 0x00 characters
3876
+ * @param {string} endian - ``big`` or ``little``
3877
+ *
3878
+ * @return string
3879
+ */
3880
+ pstring(lengthReadSize, stripNull, endian) {
3881
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: lengthReadSize, stripNull: stripNull, endian: endian });
3882
+ }
3883
+ /**
3884
+ * Reads Pascal string 1 byte length read
3885
+ *
3886
+ * @param {boolean} stripNull - removes 0x00 characters
3887
+ * @param {string} endian - ``big`` or ``little``
3888
+ *
3889
+ * @return string
3890
+ */
3891
+ pstring1(stripNull, endian) {
3892
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 1, stripNull: stripNull, endian: endian });
3893
+ }
3894
+ /**
3895
+ * Reads Pascal string 1 byte length read in little endian order
3896
+ *
3897
+ * @param {boolean} stripNull - removes 0x00 characters
3898
+ *
3899
+ * @return string
3900
+ */
3901
+ pstring1le(stripNull) {
3902
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 1, stripNull: stripNull, endian: "little" });
3903
+ }
3904
+ /**
3905
+ * Reads Pascal string 1 byte length read in big endian order
3906
+ *
3907
+ * @param {boolean} stripNull - removes 0x00 characters
3908
+ *
3909
+ * @return string
3910
+ */
3911
+ pstring1be(stripNull) {
3912
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 1, stripNull: stripNull, endian: "big" });
3913
+ }
3914
+ /**
3915
+ * Reads Pascal string 2 byte length read
3916
+ *
3917
+ * @param {boolean} stripNull - removes 0x00 characters
3918
+ * @param {string} endian - ``big`` or ``little``
3919
+ *
3920
+ * @return string
3921
+ */
3922
+ pstring2(stripNull, endian) {
3923
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 2, stripNull: stripNull, endian: endian });
3924
+ }
3925
+ /**
3926
+ * Reads Pascal string 2 byte length read in little endian order
3927
+ *
3928
+ * @param {boolean} stripNull - removes 0x00 characters
3929
+ *
3930
+ * @return string
3931
+ */
3932
+ pstring2le(stripNull) {
3933
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 2, stripNull: stripNull, endian: "little" });
3934
+ }
3935
+ /**
3936
+ * Reads Pascal string 2 byte length read in big endian order
3937
+ *
3938
+ * @param {boolean} stripNull - removes 0x00 characters
3939
+ *
3940
+ * @return string
3941
+ */
3942
+ pstring2be(stripNull) {
3943
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 2, stripNull: stripNull, endian: "big" });
3944
+ }
3945
+ /**
3946
+ * Reads Pascal string 4 byte length read
3947
+ *
3948
+ * @param {boolean} stripNull - removes 0x00 characters
3949
+ * @param {string} endian - ``big`` or ``little``
3950
+ *
3951
+ * @return string
3952
+ */
3953
+ pstring4(stripNull, endian) {
3954
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 4, stripNull: stripNull, endian: endian });
3955
+ }
3956
+ /**
3957
+ * Reads Pascal string 4 byte length read in little endian order
3958
+ *
3959
+ * @param {boolean} stripNull - removes 0x00 characters
3960
+ *
3961
+ * @return string
3962
+ */
3963
+ pstring4le(stripNull) {
3964
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 4, stripNull: stripNull, endian: "little" });
3965
+ }
3966
+ /**
3967
+ * Reads Pascal string 4 byte length read in big endian order
3968
+ *
3969
+ * @param {boolean} stripNull - removes 0x00 characters
3970
+ *
3971
+ * @return string
3972
+ */
3973
+ pstring4be(stripNull) {
3974
+ return this.string({ stringType: "pascal", encoding: "utf-8", lengthReadSize: 4, stripNull: stripNull, endian: "big" });
3975
+ }
3976
+ /**
3977
+ * Reads Wide-Pascal string
3978
+ *
3979
+ * @param {number} lengthReadSize - 1, 2 or 4 byte length write size (default 1)
3980
+ * @param {boolean} stripNull - removes 0x00 characters
3981
+ * @param {string} endian - ``big`` or ``little``
3982
+ *
3983
+ * @return string
3984
+ */
3985
+ wpstring(lengthReadSize, stripNull, endian) {
3986
+ return this.string({ stringType: "wide-pascal", encoding: "utf-16", lengthReadSize: lengthReadSize, endian: endian, stripNull: stripNull });
3987
+ }
3988
+ /**
3989
+ * Reads Wide-Pascal string 1 byte length read
3990
+ *
3991
+ * @param {boolean} stripNull - removes 0x00 characters
3992
+ * @param {string} endian - ``big`` or ``little``
3993
+ *
3994
+ * @return string
3995
+ */
3996
+ wpstring1(stripNull, endian) {
3997
+ return this.string({ stringType: "wide-pascal", encoding: "utf-16", lengthReadSize: 1, endian: endian, stripNull: stripNull });
3998
+ }
3999
+ /**
4000
+ * Reads Wide-Pascal string 2 byte length read
4001
+ *
4002
+ * @param {boolean} stripNull - removes 0x00 characters
4003
+ * @param {string} endian - ``big`` or ``little``
4004
+ *
4005
+ * @return string
4006
+ */
4007
+ wpstring2(stripNull, endian) {
4008
+ return this.string({ stringType: "wide-pascal", encoding: "utf-16", lengthReadSize: 2, endian: endian, stripNull: stripNull });
4009
+ }
4010
+ /**
4011
+ * Reads Wide-Pascal string 2 byte length read in little endian order
4012
+ *
4013
+ * @param {boolean} stripNull - removes 0x00 characters
4014
+ *
4015
+ * @return string
4016
+ */
4017
+ wpstring2le(stripNull) {
4018
+ return this.string({ stringType: "wide-pascal", encoding: "utf-16", lengthReadSize: 2, endian: "little", stripNull: stripNull });
4019
+ }
4020
+ /**
4021
+ * Reads Wide-Pascal string 2 byte length read in big endian order
4022
+ *
4023
+ * @param {boolean} stripNull - removes 0x00 characters
4024
+ *
4025
+ * @return string
4026
+ */
4027
+ wpstring2be(stripNull) {
4028
+ return this.string({ stringType: "wide-pascal", encoding: "utf-16", lengthReadSize: 2, endian: "big", stripNull: stripNull });
4029
+ }
4030
+ /**
4031
+ * Reads Wide-Pascal string 4 byte length read
4032
+ *
4033
+ * @param {boolean} stripNull - removes 0x00 characters
4034
+ * @param {string} endian - ``big`` or ``little``
4035
+ *
4036
+ * @return string
4037
+ */
4038
+ wpstring4(stripNull, endian) {
4039
+ return this.string({ stringType: "wide-pascal", encoding: "utf-16", lengthReadSize: 4, endian: endian, stripNull: stripNull });
4040
+ }
4041
+ /**
4042
+ * Reads Wide-Pascal string 4 byte length read in big endian order
4043
+ *
4044
+ * @param {boolean} stripNull - removes 0x00 characters
4045
+ *
4046
+ * @return string
4047
+ */
4048
+ wpstring4be(stripNull) {
4049
+ return this.string({ stringType: "wide-pascal", encoding: "utf-16", lengthReadSize: 4, endian: "big", stripNull: stripNull });
4050
+ }
4051
+ /**
4052
+ * Reads Wide-Pascal string 4 byte length read in little endian order
4053
+ *
4054
+ * @param {boolean} stripNull - removes 0x00 characters
4055
+ *
4056
+ * @return string
4057
+ */
4058
+ wpstring4le(stripNull) {
4059
+ return this.string({ stringType: "wide-pascal", encoding: "utf-16", lengthReadSize: 4, endian: "little", stripNull: stripNull });
4060
+ }
4061
+ }
4062
+ exports.default = bireader;