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