bireader 1.0.26 → 1.0.28

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