bireader 1.0.14 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,35 @@
1
1
  /// <reference types="node" />
2
2
  /**
3
+ * Binary reader, includes bitfields and strings
3
4
  *
4
- * byte reader, includes bitfields and strings
5
- *
6
- * @param {Buffer|Uint8Array} data - ```Buffer``` or ```Uint8Array```
7
- * @param {number} byteOffset - byte offset to start reader, default is 0
8
- * @param {number} bitOffset - bit offset to start reader, 0-7
9
- * @param {string} endianness - endianness ```big``` or ```little``` (default ```little```)
5
+ * @param {Buffer|Uint8Array} data - ```Buffer``` or ```Uint8Array```. Always found in ``biwriter.data``
6
+ * @param {number} byteOffset - Byte offset to start reader (default 0)
7
+ * @param {number} bitOffset - Bit offset 0-7 to start reader (default 0)
8
+ * @param {string} endianness - Endianness ```big``` or ```little``` (default ```little```)
9
+ * @param {boolean} strict - Strict mode: if true does not extend supplied array on outside write (default true)
10
10
  */
11
11
  export declare class bireader {
12
12
  endian: string;
13
13
  offset: number;
14
14
  bitoffset: number;
15
15
  size: number;
16
+ strict: boolean;
16
17
  errorDump: boolean;
17
- data: Array<Buffer | Uint8Array>;
18
- private check_size;
18
+ data: any;
19
19
  private isBuffer;
20
20
  private isBufferOrUint8Array;
21
+ extendArray(to_padd: number): void;
22
+ private check_size;
21
23
  /**
24
+ * Binary reader, includes bitfields and strings
22
25
  *
23
- * byte reader, includes bitfields and strings
24
- *
25
- * @param {Buffer|Uint8Array} data - ```Buffer``` or ```Uint8Array```
26
- * @param {number} byteOffset - byte offset to start reader, default is 0
27
- * @param {number} bitOffset - bit offset to start reader, 0-7
28
- * @param {string} endianness - endianness ```big``` or ```little``` (default ```little```)
26
+ * @param {Buffer|Uint8Array} data - ```Buffer``` or ```Uint8Array```. Always found in ``biwriter.data``
27
+ * @param {number} byteOffset - Byte offset to start reader (default 0)
28
+ * @param {number} bitOffset - Bit offset 0-7 to start reader (default 0)
29
+ * @param {string} endianness - Endianness ```big``` or ```little``` (default ```little```)
30
+ * @param {boolean} strict - Strict mode: if true does not extend supplied array on outside write (default true)
29
31
  */
30
- constructor(data: Array<Buffer | Uint8Array>, byteOffset?: number, bitOffset?: number, endianness?: string);
32
+ constructor(data: Array<Buffer | Uint8Array>, byteOffset?: number, bitOffset?: number, endianness?: string, strict?: boolean);
31
33
  /**
32
34
  *
33
35
  * Change endian, defaults to little
@@ -62,203 +64,430 @@ export declare class bireader {
62
64
  */
63
65
  le(): void;
64
66
  /**
65
- * Move current read byte or bit position
67
+ * Offset current byte or bit position
68
+ * Note: Will extend array if strict mode is off and outside of max size
66
69
  *
67
- * @param {number} bytes - bytes to skip
68
- * @param {number} bits - bits to skip
70
+ * @param {number} bytes - Bytes to skip
71
+ * @param {number} bits - Bits to skip (0-7)
69
72
  */
70
73
  skip(bytes: number, bits?: number): void;
71
74
  /**
72
- * Move current read byte or bit position
75
+ * Offset current byte or bit position
76
+ * Note: Will extend array if strict mode is off and outside of max size
73
77
  *
74
- * @param {number} bytes - bytes to skip
75
- * @param {number} bits - bits to skip
78
+ * @param {number} bytes - Bytes to skip
79
+ * @param {number} bits - Bits to skip (0-7)
76
80
  */
77
- fskip(bytes: number, bits?: number): void;
81
+ jump(bytes: number, bits?: number): void;
78
82
  /**
79
- * Change current byte or bit read position
83
+ * Change position directly to address
84
+ * Note: Will extend array if strict mode is off and outside of max size
80
85
  *
81
- * @param {number} byte - byte to jump to
82
- * @param {number} bit - bit to jump to (0-7)
86
+ * @param {number} byte - byte to set to
87
+ * @param {number} bit - bit to set to (0-7)
83
88
  */
84
89
  goto(byte: number, bit?: number): void;
85
90
  /**
86
- * Change current byte or bit read position
91
+ * Change position directly to address
92
+ * Note: Will extend array if strict mode is off and outside of max size
87
93
  *
88
- * @param {number} byte - byte to jump to
89
- * @param {number} bit - bit to jump to (0-7)
94
+ * @param {number} byte - byte to set to
95
+ * @param {number} bit - bit to set to (0-7)
90
96
  */
91
97
  seek(byte: number, bit?: number): void;
92
98
  /**
93
- * Change current byte or bit read position
99
+ * Change position directly to address
100
+ * Note: Will extend array if strict mode is off and outside of max size
94
101
  *
95
- * @param {number} byte - byte to jump to
96
- * @param {number} bit - bit to jump to (0-7)
102
+ * @param {number} byte - byte to set to
103
+ * @param {number} bit - bit to set to (0-7)
97
104
  */
98
- fseek(byte: number, bit?: number): void;
105
+ pointer(byte: number, bit?: number): void;
99
106
  /**
100
- * Change current byte or bit read position
107
+ * Change position directly to address
108
+ * Note: Will extend array if strict mode is off and outside of max size
101
109
  *
102
- * @param {number} byte - byte to jump to
103
- * @param {number} bit - bit to jump to (0-7)
110
+ * @param {number} byte - byte to set to
111
+ * @param {number} bit - bit to set to (0-7)
112
+ */
113
+ warp(byte: number, bit?: number): void;
114
+ /**
115
+ * Set byte and bit position to start of data
104
116
  */
105
- jump(byte: number, bit?: number): void;
117
+ rewind(): void;
106
118
  /**
107
- * Change current byte or bit read position
119
+ * Set byte and bit position to start of data
120
+ */
121
+ gotostart(): void;
122
+ /**
123
+ * Get the current byte position
108
124
  *
109
- * @param {number} byte - byte to jump to
110
- * @param {number} bit - bit to jump to (0-7)
125
+ * @return {number} current byte position
111
126
  */
112
- pointer(byte: number, bit?: number): void;
127
+ tell(): number;
113
128
  /**
114
- * Change current byte or bit read position
129
+ * Get the current byte position
115
130
  *
116
- * @param {number} byte - byte to jump to
117
- * @param {number} bit - bit to jump to (0-7)
131
+ * @return {number} current byte position
118
132
  */
119
- warp(byte: number, bit?: number): void;
133
+ getOffset(): number;
120
134
  /**
121
- * Change current byte or bit read position
135
+ * Get the current byte position
122
136
  *
123
- * @param {number} byte - byte to jump to
124
- * @param {number} bit - bit to jump to (0-7)
137
+ * @return {number} current byte position
125
138
  */
126
- fsetpos(byte: number, bit?: number): void;
139
+ saveOffset(): number;
127
140
  /**
128
- * Set offset to start of file
141
+ * Get the current bit position (0-7)
142
+ *
143
+ * @return {number} current bit position
129
144
  */
130
- rewind(): void;
145
+ tellB(): number;
131
146
  /**
132
- * Set offset to start of file
147
+ * Get the current bit position (0-7)
148
+ *
149
+ * @return {number} current bit position
133
150
  */
134
- gotostart(): void;
151
+ getOffsetBit(): number;
135
152
  /**
136
- * Set offset to start of file
153
+ * Get the current bit position (0-7)
154
+ *
155
+ * @return {number} current bit position
137
156
  */
138
- tostart(): void;
157
+ saveOffsetAbsBit(): number;
139
158
  /**
140
- * Get the current byte position
159
+ * Get the current absolute bit position (from start of data)
141
160
  *
142
- * @return {number} current byte position
161
+ * @return {number} current absolute bit position
143
162
  */
144
- ftell(): number;
163
+ tellAbsB(): number;
145
164
  /**
146
- * Get the current byte position
165
+ * Get the current absolute bit position (from start of data)
147
166
  *
148
- * @return {number} current byte position
167
+ * @return {number} current absolute bit position
149
168
  */
150
- tell(): number;
169
+ getOffsetAbsBit(): number;
151
170
  /**
152
- * Get the current byte position
171
+ * Get the current absolute bit position (from start of data)
153
172
  *
154
- * @return {number} current byte position
173
+ * @return {number} current absolute bit position
155
174
  */
156
- fgetpos(): number;
175
+ saveOffsetBit(): number;
157
176
  /**
158
- * Get the current byte position
177
+ * Disallows extending data if position is outside of max size
178
+ */
179
+ restrict(): void;
180
+ /**
181
+ * Allows extending data if position is outside of max size
182
+ */
183
+ unrestrict(): void;
184
+ /**
185
+ * XOR data
159
186
  *
160
- * @return {number} current byte position
187
+ * @param {number|string|Uint8Array|Buffer} xorKey - Value, string or array to XOR
188
+ * @param {number} startOffset - Start location (default current byte position)
189
+ * @param {number} endOffset - End location (default end of data)
190
+ * @param {boolean} consume - Move current position to end of data (default false)
161
191
  */
162
- saveOffset(): number;
192
+ xor(xorKey: number | string | Uint8Array | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
163
193
  /**
164
- * Truncates array from start to current position unless supplied
165
- * Note: Does not affect supplied data
166
- * @param {number} startOffset - Start location, default 0
167
- * @param {number} endOffset - end location, default current write position
168
- * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
194
+ * XOR data
195
+ *
196
+ * @param {number|string|Uint8Array|Buffer} xorKey - Value, string or array to XOR
197
+ * @param {number} length - Length in bytes to XOR from curent position (default 1 byte for value, length of string or array for Uint8Array or Buffer)
198
+ * @param {boolean} consume - Move current position to end of data (default false)
169
199
  */
170
- clip(startOffset?: number, endOffset?: number): Array<Buffer | Uint8Array>;
200
+ xorThis(xorKey: number | string | Uint8Array | Buffer, length?: number, consume?: boolean): void;
171
201
  /**
172
- * Truncates array from start to current position unless supplied
173
- * Note: Does not affect supplied data
174
- * @param {number} startOffset - Start location, default 0
175
- * @param {number} endOffset - end location, default current write position
176
- * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
202
+ * OR data
203
+ *
204
+ * @param {number|string|Uint8Array|Buffer} orKey - Value, string or array to OR
205
+ * @param {number} startOffset - Start location (default current byte position)
206
+ * @param {number} endOffset - End location (default end of data)
207
+ * @param {boolean} consume - Move current position to end of data (default false)
177
208
  */
178
- crop(startOffset?: number, endOffset?: number): Array<Buffer | Uint8Array>;
209
+ or(orKey: number | string | Uint8Array | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
179
210
  /**
180
- * Truncates array from start to current position unless supplied
181
- * Note: Does not affect supplied data
182
- * @param {number} startOffset - Start location, default 0
183
- * @param {number} endOffset - end location, default current write position
184
- * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
211
+ * OR data
212
+ *
213
+ * @param {number|string|Uint8Array|Buffer} orKey - Value, string or array to OR
214
+ * @param {number} length - Length in bytes to OR from curent position (default 1 byte for value, length of string or array for Uint8Array or Buffer)
215
+ * @param {boolean} consume - Move current position to end of data (default false)
185
216
  */
186
- truncate(startOffset?: number, endOffset?: number): Array<Buffer | Uint8Array>;
217
+ orThis(orKey: number | string | Uint8Array | Buffer, length?: number, consume?: boolean): void;
187
218
  /**
188
- * Truncates array from start to current position unless supplied
189
- * Note: Does not affect supplied data
190
- * @param {number} startOffset - Start location, default 0
191
- * @param {number} endOffset - end location, default current write position
192
- * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
219
+ * AND data
220
+ *
221
+ * @param {number|string|Uint8Array|Buffer} andKey - Value, string or array to AND
222
+ * @param {number} startOffset - Start location (default current byte position)
223
+ * @param {number} endOffset - End location (default end of data)
224
+ * @param {boolean} consume - Move current position to end of data (default false)
225
+ */
226
+ and(andKey: number | string | Uint8Array | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
227
+ /**
228
+ * AND data
229
+ *
230
+ * @param {number|string|Uint8Array|Buffer} andKey - Value, string or array to AND
231
+ * @param {number} length - Length in bytes to AND from curent position (default 1 byte for value, length of string or array for Uint8Array or Buffer)
232
+ * @param {boolean} consume - Move current position to end of data (default false)
233
+ */
234
+ andThis(andKey: number | string | Uint8Array | Buffer, length?: number, consume?: boolean): void;
235
+ /**
236
+ * Not data
237
+ *
238
+ * @param {number} startOffset - Start location (default current byte position)
239
+ * @param {number} endOffset - End location (default end of data)
240
+ * @param {boolean} consume - Move current position to end of data (default false)
241
+ */
242
+ not(startOffset?: number, endOffset?: number, consume?: boolean): void;
243
+ /**
244
+ * Not data
245
+ *
246
+ * @param {number} length - Length in bytes to NOT from curent position (default 1 byte for value, length of string or array for Uint8Array or Buffer)
247
+ * @param {boolean} consume - Move current position to end of data (default false)
248
+ */
249
+ notThis(length?: number, consume?: boolean): void;
250
+ /**
251
+ * Left shift data
252
+ *
253
+ * @param {number} shiftValue - Value to left shift
254
+ * @param {number} startOffset - Start location (default current byte position)
255
+ * @param {number} endOffset - End location (default end of data)
256
+ * @param {boolean} consume - Move current position to end of data (default false)
257
+ */
258
+ lShift(shiftValue: number, startOffset?: number, endOffset?: number, consume?: boolean): void;
259
+ /**
260
+ * Left shift data
261
+ *
262
+ * @param {number} shiftValue - Value to left shift
263
+ * @param {number} length - Length in bytes to left shift from curent position (default 1 byte for value, length of string or array for Uint8Array or Buffer)
264
+ * @param {boolean} consume - Move current position to end of data (default false)
265
+ */
266
+ lShiftThis(shiftValue: number, length?: number, consume?: boolean): void;
267
+ /**
268
+ * Right shift data
269
+ *
270
+ * @param {number} shiftValue - Value to right shift
271
+ * @param {number} startOffset - Start location (default current byte position)
272
+ * @param {number} endOffset - End location (default end of data)
273
+ * @param {boolean} consume - Move current position to end of data (default false)
274
+ */
275
+ rShift(shiftValue: number, startOffset?: number, endOffset?: number, consume?: boolean): void;
276
+ /**
277
+ * Right shift data
278
+ *
279
+ * @param {number} shiftValue - Value to right shift
280
+ * @param {number} length - Length in bytes to right shift from curent position (default 1 byte for value, length of string or array for Uint8Array or Buffer)
281
+ * @param {boolean} consume - Move current position to end of data (default false)
282
+ */
283
+ rShiftThis(shiftValue: number, length?: number, consume?: boolean): void;
284
+ /**
285
+ * Add value to data
286
+ *
287
+ * @param {number} addValue - Value to add
288
+ * @param {number} startOffset - Start location (default current byte position)
289
+ * @param {number} endOffset - End location (default end of data)
290
+ * @param {boolean} consume - Move current position to end of data (default false)
291
+ */
292
+ add(addValue: number, startOffset?: number, endOffset?: number, consume?: boolean): void;
293
+ /**
294
+ * Add value to data
295
+ *
296
+ * @param {number} addValue - Value to add
297
+ * @param {number} length - Length in bytes to add from curent position (default 1 byte for value, length of string or array for Uint8Array or Buffer)
298
+ * @param {boolean} consume - Move current position to end of data (default false)
299
+ */
300
+ addThis(addValue: number, length?: number, consume?: boolean): void;
301
+ /**
302
+ * Deletes part of data from start to current byte position unless supplied, returns removed
303
+ * Note: Errors in strict mode
304
+ *
305
+ * @param {number} startOffset - Start location (default 0)
306
+ * @param {number} endOffset - End location (default current position)
307
+ * @param {boolean} consume - Move position to end of removed data (default false)
308
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
309
+ */
310
+ delete(startOffset?: number, endOffset?: number, consume?: boolean): Array<Buffer | Uint8Array>;
311
+ /**
312
+ * Deletes part of data from start to current byte position unless supplied, returns removed
313
+ * Note: Errors in strict mode
314
+ *
315
+ * @param {number} startOffset - Start location (default 0)
316
+ * @param {number} endOffset - End location (default current position)
317
+ * @param {boolean} consume - Move position to end of removed data (default false)
318
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
319
+ */
320
+ clip(startOffset?: number, endOffset?: number, consume?: boolean): Array<Buffer | Uint8Array>;
321
+ /**
322
+ * Deletes part of data from current byte position to supplied length, returns removed
323
+ * Note: Errors in strict mode
324
+ *
325
+ * @param {number} length - Length of data in bytes to remove
326
+ * @param {boolean} consume - Move position to end of removed data (default false)
327
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
328
+ */
329
+ crop(length: number, consume?: boolean): Array<Buffer | Uint8Array>;
330
+ /**
331
+ * Deletes part of data from current position to supplied length, returns removed
332
+ * Note: Only works in strict mode
333
+ *
334
+ * @param {number} length - Length of data in bytes to remove
335
+ * @param {boolean} consume - Move position to end of removed data (default false)
336
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
337
+ */
338
+ drop(length: number, consume?: boolean): Array<Buffer | Uint8Array>;
339
+ /**
340
+ * Returns part of data from current byte position to end of data unless supplied
341
+ *
342
+ * @param {number} startOffset - Start location (default current position)
343
+ * @param {number} endOffset - End location (default end of data)
344
+ * @param {boolean} consume - Move position to end of lifted data (default false)
345
+ * @param {number} fillValue - Byte value to to fill returned data (does NOT fill unless supplied)
346
+ * @returns {Buffer|Uint8Array} Selected data as ```Uint8Array``` or ```Buffer```
193
347
  */
194
- slice(startOffset?: number, endOffset?: number): Array<Buffer | Uint8Array>;
348
+ lift(startOffset?: number, endOffset?: number, consume?: boolean, fillValue?: number): Array<Buffer | Uint8Array>;
195
349
  /**
196
- * Extract array from current position to length supplied
350
+ * Returns part of data from current byte position to end of data unless supplied
351
+ *
352
+ * @param {number} startOffset - Start location (default current position)
353
+ * @param {number} endOffset - End location (default end of data)
354
+ * @param {boolean} consume - Move position to end of lifted data (default false)
355
+ * @param {number} fillValue - Byte value to to fill returned data (does NOT fill unless supplied)
356
+ * @returns {Buffer|Uint8Array} Selected data as ```Uint8Array``` or ```Buffer```
357
+ */
358
+ fill(startOffset?: number, endOffset?: number, consume?: boolean, fillValue?: number): Array<Buffer | Uint8Array>;
359
+ /**
360
+ * Extract data from current position to length supplied
197
361
  * Note: Does not affect supplied data
198
- * @param {number} length - length of data to copy from current offset
199
- * @param {number} consume - moves offset to end of length
200
- * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
362
+ *
363
+ * @param {number} length - Length of data in bytes to copy from current offset
364
+ * @param {number} consume - Moves offset to end of length
365
+ * @returns {Buffer|Uint8Array} Selected data as ```Uint8Array``` or ```Buffer```
201
366
  */
202
367
  extract(length: number, consume?: boolean): Array<Buffer | Uint8Array>;
203
368
  /**
204
- * Extract array from current position to length supplied
369
+ * Extract data from current position to length supplied
205
370
  * Note: Does not affect supplied data
206
- * @param {number} length - length of data to copy from current offset
207
- * @param {number} consume - moves offset to end of length
208
- * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
371
+ *
372
+ * @param {number} length - Length of data in bytes to copy from current offset
373
+ * @param {number} consume - Moves offset to end of length
374
+ * @returns {Buffer|Uint8Array} Selected data as ```Uint8Array``` or ```Buffer```
209
375
  */
210
- wrap(length: number, consume?: boolean): Array<Buffer | Uint8Array>;
376
+ slice(length: number, consume?: boolean): Array<Buffer | Uint8Array>;
211
377
  /**
212
- * Extract array from current position to length supplied
378
+ * Extract data from current position to length supplied
213
379
  * Note: Does not affect supplied data
214
- * @param {number} length - length of data to copy from current offset
215
- * @param {number} consume - moves offset to end of length
216
- * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
380
+ *
381
+ * @param {number} length - Length of data in bytes to copy from current offset
382
+ * @param {number} consume - Moves offset to end of length
383
+ * @returns {Buffer|Uint8Array} Selected data as ```Uint8Array``` or ```Buffer```
217
384
  */
218
- lift(length: number, consume?: boolean): Array<Buffer | Uint8Array>;
385
+ wrap(length: number, consume?: boolean): Array<Buffer | Uint8Array>;
386
+ /**
387
+ * Inserts data into data
388
+ * Note: Must be same data type as supplied data. Errors on strict mode.
389
+ *
390
+ * @param {Buffer|Uint8Array} data - ```Uint8Array``` or ```Buffer``` to add to data
391
+ * @param {boolean} consume - Move current byte position to end of data (default false)
392
+ * @param {number} offset - Byte position to add at (defaults to current position)
393
+ */
394
+ insert(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
395
+ /**
396
+ * Inserts data into data
397
+ * Note: Must be same data type as supplied data. Errors on strict mode.
398
+ *
399
+ * @param {Buffer|Uint8Array} data - ```Uint8Array``` or ```Buffer``` to add to data
400
+ * @param {boolean} consume - Move current byte position to end of data (default false)
401
+ * @param {number} offset - Byte position to add at (defaults to current position)
402
+ */
403
+ place(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
404
+ /**
405
+ * Replaces data in data
406
+ * Note: Must be same data type as supplied data. Errors on strict mode.
407
+ *
408
+ * @param {Buffer|Uint8Array} data - ```Uint8Array``` or ```Buffer``` to replace in data
409
+ * @param {boolean} consume - Move current byte position to end of data (default false)
410
+ * @param {number} offset - Offset to add it at (defaults to current position)
411
+ */
412
+ replace(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
413
+ /**
414
+ * Replaces data in data
415
+ * Note: Must be same data type as supplied data. Errors on strict mode.
416
+ *
417
+ * @param {Buffer|Uint8Array} data - ```Uint8Array``` or ```Buffer``` to replace in data
418
+ * @param {boolean} consume - Move current byte position to end of data (default false)
419
+ * @param {number} offset - Offset to add it at (defaults to current position)
420
+ */
421
+ overwrite(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
422
+ /**
423
+ * Adds data to start of supplied data
424
+ * Note: Must be same data type as supplied data. Errors on strict mode.
425
+ *
426
+ * @param {Buffer|Uint8Array} data - ```Uint8Array``` or ```Buffer``` to add to data
427
+ * @param {boolean} consume - Move current write position to end of data (default false)
428
+ */
429
+ unshift(data: Buffer | Uint8Array, consume?: boolean): void;
430
+ /**
431
+ * Adds data to start of supplied data
432
+ * Note: Must be same data type as supplied data. Errors on strict mode.
433
+ *
434
+ * @param {Buffer|Uint8Array} data - ```Uint8Array``` or ```Buffer``` to add to data
435
+ * @param {boolean} consume - Move current write position to end of data (default false)
436
+ */
437
+ prepend(data: Buffer | Uint8Array, consume?: boolean): void;
438
+ /**
439
+ * Adds data to end of supplied data
440
+ * Note: Must be same data type as supplied data. Errors on strict mode.
441
+ *
442
+ * @param {Buffer|Uint8Array} data - ```Uint8Array``` or ```Buffer``` to add to data
443
+ * @param {boolean} consume - Move current write position to end of data (default false)
444
+ */
445
+ push(data: Buffer | Uint8Array, consume?: boolean): void;
446
+ /**
447
+ * Adds data to end of supplied data
448
+ * Note: Must be same data type as supplied data. Errors on strict mode.
449
+ *
450
+ * @param {Buffer|Uint8Array} data - ```Uint8Array``` or ```Buffer``` to add to data
451
+ * @param {boolean} consume - Move current write position to end of data (default false)
452
+ */
453
+ append(data: Buffer | Uint8Array, consume?: boolean): void;
219
454
  /**
220
455
  * Returns current data
456
+ *
221
457
  * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
222
458
  */
223
459
  get(): Array<Buffer | Uint8Array>;
224
460
  /**
225
461
  * Returns current data
462
+ *
226
463
  * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
227
464
  */
228
465
  return(): Array<Buffer | Uint8Array>;
229
466
  /**
230
- * removes reading data
467
+ * removes data
231
468
  */
232
469
  end(): void;
233
470
  /**
234
- * removes reading data
471
+ * removes data
235
472
  */
236
473
  close(): void;
237
474
  /**
238
- * removes reading data
475
+ * removes data
239
476
  */
240
477
  done(): void;
241
478
  /**
242
- * removes reading data
479
+ * removes data
243
480
  */
244
481
  finished(): void;
245
482
  /**
246
- * Turn hexdump on error off, default on
247
- */
248
- errorDumpOff(): void;
249
- /**
250
- * Turn hexdump on error on, default on
251
- */
252
- errorDumpOn(): void;
253
- /**
254
483
  * Console logs data as hex dump
255
484
  *
256
- * @param {object} options - options object
485
+ * @param {object} options
257
486
  * ```javascript
258
487
  * {
259
488
  * length: 192, // number of bytes to log, default 192 or end of data
260
- * startByte: 0, // byte to start dump, default current position
261
- * supressUnicode: false // Supress unicode character preview for cleaner columns
489
+ * startByte: 0, // byte to start dump (default current byte position)
490
+ * supressUnicode: false // Supress unicode character preview for even columns
262
491
  * }
263
492
  * ```
264
493
  */
@@ -268,6 +497,26 @@ export declare class bireader {
268
497
  supressUnicode?: boolean;
269
498
  }): void;
270
499
  /**
500
+ * Turn hexdump on error off (default on)
501
+ */
502
+ errorDumpOff(): void;
503
+ /**
504
+ * Turn hexdump on error on (default on)
505
+ */
506
+ errorDumpOn(): void;
507
+ /**
508
+ *
509
+ * Write bits, must have at least value and number of bits
510
+ *
511
+ * ``Note``: When returning to a byte write, remaining bits are skipped
512
+ *
513
+ * @param {number} value - value as int
514
+ * @param {number} bits - number of bits to write
515
+ * @param {boolean} unsigned - if value is unsigned
516
+ * @param {string} endian - ``big`` or ``little``
517
+ */
518
+ writeBit(value: number, bits: number, unsigned?: boolean, endian?: string): void;
519
+ /**
271
520
  * Bit field reader
272
521
  *
273
522
  * Note: When returning to a byte read, remaining bits are dropped
@@ -295,9 +544,10 @@ export declare class bireader {
295
544
  * Note: When returning to a byte read, remaining bits are dropped
296
545
  *
297
546
  * @param {boolean} unsigned - if the value is unsigned
547
+ * @param {string} endian - ``big`` or ``little`
298
548
  * @returns number
299
549
  */
300
- bit1(unsigned?: boolean): number;
550
+ bit1(unsigned?: boolean, endian?: string): number;
301
551
  /**
302
552
  * Bit field reader
303
553
  *
@@ -2005,6 +2255,13 @@ export declare class bireader {
2005
2255
  */
2006
2256
  readByte(unsigned?: boolean): number;
2007
2257
  /**
2258
+ * Write byte
2259
+ *
2260
+ * @param {number} value - value as int
2261
+ * @param {boolean} unsigned - if the value is unsigned
2262
+ */
2263
+ writeByte(value: number, unsigned?: boolean): void;
2264
+ /**
2008
2265
  * Read byte
2009
2266
  *
2010
2267
  * @param {boolean} unsigned - if value is unsigned or not
@@ -2045,6 +2302,14 @@ export declare class bireader {
2045
2302
  */
2046
2303
  readInt16(unsigned?: boolean, endian?: string): number;
2047
2304
  /**
2305
+ * Write int16
2306
+ *
2307
+ * @param {number} value - value as int
2308
+ * @param {boolean} unsigned - if the value is unsigned
2309
+ * @param {string} endian - ``big`` or ``little`
2310
+ */
2311
+ writeInt16(value: number, unsigned?: boolean, endian?: string): void;
2312
+ /**
2048
2313
  * Read short
2049
2314
  *
2050
2315
  * @param {boolean} unsigned - if value is unsigned or not
@@ -2204,6 +2469,13 @@ export declare class bireader {
2204
2469
  */
2205
2470
  readHalfFloat(endian?: string): number;
2206
2471
  /**
2472
+ * Writes half float
2473
+ *
2474
+ * @param {number} value - value as int
2475
+ * @param {string} endian - ``big`` or ``little`
2476
+ */
2477
+ writeHalfFloat(value: number, endian?: string): void;
2478
+ /**
2207
2479
  * Read half float
2208
2480
  *
2209
2481
  * @param {string} endian - ```big``` or ```little```
@@ -2262,6 +2534,14 @@ export declare class bireader {
2262
2534
  */
2263
2535
  readInt32(unsigned?: boolean, endian?: string): number;
2264
2536
  /**
2537
+ * Write int32
2538
+ *
2539
+ * @param {number} value - value as int
2540
+ * @param {boolean} unsigned - if the value is unsigned
2541
+ * @param {string} endian - ``big`` or ``little`
2542
+ */
2543
+ writeInt32(value: number, unsigned?: boolean, endian?: string): void;
2544
+ /**
2265
2545
  * Read 32 bit integer
2266
2546
  *
2267
2547
  * @param {boolean} unsigned - if value is unsigned or not
@@ -2451,6 +2731,13 @@ export declare class bireader {
2451
2731
  */
2452
2732
  readFloat(endian?: string): number;
2453
2733
  /**
2734
+ * Write float
2735
+ *
2736
+ * @param {number} value - value as int
2737
+ * @param {string} endian - ``big`` or ``little`
2738
+ */
2739
+ writeFloat(value: number, endian?: string): void;
2740
+ /**
2454
2741
  * Read float
2455
2742
  *
2456
2743
  * @param {string} endian - ```big``` or ```little```
@@ -2489,6 +2776,14 @@ export declare class bireader {
2489
2776
  */
2490
2777
  readInt64(unsigned?: boolean, endian?: string): bigint;
2491
2778
  /**
2779
+ * Write 64 bit integer
2780
+ *
2781
+ * @param {number} value - value as int
2782
+ * @param {boolean} unsigned - if the value is unsigned
2783
+ * @param {string} endian - ``big`` or ``little`
2784
+ */
2785
+ writeInt64(value: number, unsigned?: boolean, endian?: string): void;
2786
+ /**
2492
2787
  * Read signed 64 bit integer
2493
2788
  * @param {boolean} unsigned - if value is unsigned or not
2494
2789
  * @param {string} endian - ```big``` or ```little```
@@ -2637,6 +2932,14 @@ export declare class bireader {
2637
2932
  */
2638
2933
  readDoubleFloat(endian?: string): number;
2639
2934
  /**
2935
+ * Writes double float
2936
+ *
2937
+ * @param {number} value - value as int
2938
+ * @param {number} offset - byte offset (default last write position)
2939
+ * @param {string} endian - ``big`` or ``little`
2940
+ */
2941
+ writeDoubleFloat(value: number, endian?: string): void;
2942
+ /**
2640
2943
  * Read double float
2641
2944
  *
2642
2945
  * @param {string} endian - ```big``` or ```little```
@@ -2712,6 +3015,49 @@ export declare class bireader {
2712
3015
  encoding?: string;
2713
3016
  endian?: string;
2714
3017
  }): string;
3018
+ /**
3019
+ * Writes string, use options object for different types
3020
+ *
3021
+ *
3022
+ * @param {string} string - text string
3023
+ * @param {object} options - options:
3024
+ * ```javascript
3025
+ * {
3026
+ * length: string.length, //for fixed length, non-terminate value utf strings
3027
+ * stringType: "utf-8", //utf-8, utf-16, pascal or wide-pascal
3028
+ * terminateValue: 0x00, // only with stringType: "utf"
3029
+ * lengthWriteSize: 1, //for pascal strings. 1, 2 or 4 byte length write size
3030
+ * encoding: "utf-8", //TextEncoder accepted types
3031
+ * endian: "little", //for wide-pascal and utf-16
3032
+ * }
3033
+ * ```
3034
+ */
3035
+ writeString(string: string, options?: {
3036
+ length?: number;
3037
+ stringType?: string;
3038
+ terminateValue?: number;
3039
+ lengthWriteSize?: number;
3040
+ stripNull?: boolean;
3041
+ encoding?: string;
3042
+ endian?: string;
3043
+ }): void;
3044
+ /**
3045
+ * Reads string, use options object for different types
3046
+ *
3047
+ * @param {object} options
3048
+ * ```javascript
3049
+ * {
3050
+ * length: number, //for fixed length, non-terminate value utf strings
3051
+ * stringType: "utf-8", //utf-8, utf-16, pascal or wide-pascal
3052
+ * terminateValue: 0x00, // only for non-fixed length utf strings
3053
+ * lengthReadSize: 1, //for pascal strings. 1, 2 or 4 byte length read size
3054
+ * stripNull: true, // removes 0x00 characters
3055
+ * encoding: "utf-8", //TextEncoder accepted types
3056
+ * endian: "little", //for wide-pascal and utf-16
3057
+ * }
3058
+ * ```
3059
+ * @return string
3060
+ */
2715
3061
  string(options?: {
2716
3062
  length?: number;
2717
3063
  stringType?: string;