bireader 1.0.25 → 1.0.27

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