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