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