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