bireader 1.0.0 → 1.0.1

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