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