bireader 3.0.1 → 3.1.0

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 (55) hide show
  1. package/README.md +91 -29
  2. package/dist/BiReader.d.ts +33 -0
  3. package/dist/BiReaderStream.d.ts +34 -0
  4. package/dist/BiWriter.d.ts +33 -0
  5. package/dist/BiWriterStream.d.ts +36 -0
  6. package/dist/aliases/BinaryAliasReader.d.ts +7 -0
  7. package/dist/aliases/BinaryAliasWriter.d.ts +7 -0
  8. package/dist/common.d.ts +90 -0
  9. package/{build/cjs/common.d.ts → dist/core/BiBase.d.ts} +132 -221
  10. package/dist/core/BiBaseStream.d.ts +1363 -0
  11. package/{build/esm/common.d.ts → dist/index.browser.d.ts} +208 -169
  12. package/dist/index.browser.js +9706 -0
  13. package/dist/index.browser.js.map +1 -0
  14. package/dist/index.cjs.d.ts +2895 -0
  15. package/dist/index.cjs.js +13662 -0
  16. package/dist/index.cjs.js.map +1 -0
  17. package/dist/index.d.ts +2895 -0
  18. package/dist/index.esm.d.ts +2895 -0
  19. package/dist/index.esm.js +13635 -0
  20. package/dist/index.esm.js.map +1 -0
  21. package/dist/indexBrowser.d.ts +19 -0
  22. package/dist/indexImport.d.ts +21 -0
  23. package/package.json +23 -14
  24. package/rollup.config.js +76 -0
  25. package/tsconfig.json +15 -0
  26. package/build/cjs/bireader.d.ts +0 -2372
  27. package/build/cjs/bireader.d.ts.map +0 -1
  28. package/build/cjs/bireader.js +0 -3060
  29. package/build/cjs/bireader.js.map +0 -1
  30. package/build/cjs/biwriter.d.ts +0 -2359
  31. package/build/cjs/biwriter.d.ts.map +0 -1
  32. package/build/cjs/biwriter.js +0 -3094
  33. package/build/cjs/biwriter.js.map +0 -1
  34. package/build/cjs/common.d.ts.map +0 -1
  35. package/build/cjs/common.js +0 -3615
  36. package/build/cjs/common.js.map +0 -1
  37. package/build/cjs/index.d.ts +0 -18
  38. package/build/cjs/index.d.ts.map +0 -1
  39. package/build/cjs/index.js +0 -30
  40. package/build/cjs/index.js.map +0 -1
  41. package/build/esm/bireader.d.ts +0 -2372
  42. package/build/esm/bireader.d.ts.map +0 -1
  43. package/build/esm/bireader.js +0 -3060
  44. package/build/esm/bireader.js.map +0 -1
  45. package/build/esm/biwriter.d.ts +0 -2359
  46. package/build/esm/biwriter.d.ts.map +0 -1
  47. package/build/esm/biwriter.js +0 -3094
  48. package/build/esm/biwriter.js.map +0 -1
  49. package/build/esm/common.d.ts.map +0 -1
  50. package/build/esm/common.js +0 -3615
  51. package/build/esm/common.js.map +0 -1
  52. package/build/esm/index.d.ts +0 -18
  53. package/build/esm/index.d.ts.map +0 -1
  54. package/build/esm/index.js +0 -30
  55. package/build/esm/index.js.map +0 -1
@@ -0,0 +1,2895 @@
1
+ /// <reference types="node" />
2
+ type endian = "little" | "big";
3
+ type BiOptions = {
4
+ /**
5
+ * Byte offset to start writer, default is 0
6
+ */
7
+ byteOffset?: number;
8
+ /**
9
+ * Byte offset to start writer, default is 0
10
+ */
11
+ bitOffset?: number;
12
+ /**
13
+ * Endianness ``big`` or ``little`` (default little)
14
+ */
15
+ endianness?: endian;
16
+ /**
17
+ * Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
18
+ */
19
+ strict?: boolean;
20
+ /**
21
+ * Amount of data to add when extending the buffer array when strict mode is false. Note: Changes login in ``.get`` and ``.return``.
22
+ */
23
+ extendBufferSize?: number;
24
+ };
25
+ type hexdumpOptions = {
26
+ /**
27
+ * number of bytes to log, default ``192`` or end of data
28
+ */
29
+ length?: number;
30
+ /**
31
+ * byte to start dump (default ``0``)
32
+ */
33
+ startByte?: number;
34
+ /**
35
+ * Supress unicode character preview for even columns.
36
+ */
37
+ supressUnicode?: boolean;
38
+ /**
39
+ * Returns the hex dump string instead of logging it.
40
+ */
41
+ returnString?: boolean;
42
+ };
43
+ /**
44
+ * Creates hex dump string. Will console log or return string if set in options.
45
+ *
46
+ * @param {Uint8Array|Buffer} src - Uint8Array or Buffer
47
+ * @param {hexdumpOptions?} options - hex dump options
48
+ * @param {number?} options.length - number of bytes to log, default ``192`` or end of data
49
+ * @param {number?} options.startByte - byte to start dump (default ``0``)
50
+ * @param {boolean?} options.supressUnicode - Supress unicode character preview for even columns.
51
+ * @param {boolean?} options.returnString - Returns the hex dump string instead of logging it.
52
+ */
53
+ declare function hexdump(src: Uint8Array | Buffer, options?: hexdumpOptions): void | string;
54
+ type stringOptions = {
55
+ /**
56
+ * for fixed length, non-terminate value utf strings
57
+ */
58
+ length?: number;
59
+ /**
60
+ * utf-8, utf-16, pascal or wide-pascal
61
+ */
62
+ stringType?: "utf-8" | "utf-16" | "pascal" | "wide-pascal";
63
+ /**
64
+ * only with stringType: "utf"
65
+ */
66
+ terminateValue?: number;
67
+ /**
68
+ * for pascal strings. 1, 2 or 4 byte length read size
69
+ */
70
+ lengthReadSize?: 1 | 2 | 4;
71
+ /**
72
+ * for pascal strings. 1, 2 or 4 byte length write size
73
+ */
74
+ lengthWriteSize?: 1 | 2 | 4;
75
+ /**
76
+ * removes 0x00 characters
77
+ */
78
+ stripNull?: boolean;
79
+ /**
80
+ * TextEncoder accepted types
81
+ */
82
+ encoding?: string;
83
+ /**
84
+ * for wide-pascal and utf-16
85
+ */
86
+ endian?: "big" | "little";
87
+ };
88
+
89
+ declare class BiBase {
90
+ /**
91
+ * Endianness of default read.
92
+ * @type {endian}
93
+ */
94
+ endian: endian;
95
+ /**
96
+ * Current read byte location.
97
+ */
98
+ offset: number;
99
+ /**
100
+ * Current read byte's bit location.
101
+ */
102
+ bitoffset: number;
103
+ /**
104
+ * Size in bytes of the current buffer.
105
+ */
106
+ size: number;
107
+ /**
108
+ * Size in bits of the current buffer.
109
+ */
110
+ sizeB: number;
111
+ /**
112
+ * Allows the buffer to extend reading or writing outside of current size
113
+ */
114
+ strict: boolean;
115
+ /**
116
+ * Console log a hexdump on error.
117
+ */
118
+ errorDump: boolean;
119
+ /**
120
+ * Current buffer data.
121
+ * @type {Buffer|Uint8Array}
122
+ */
123
+ data: any;
124
+ /**
125
+ * When the data buffer needs to be extended while strict mode is ``false``, this will be the amount it extends.
126
+ *
127
+ * Otherwise it extends just the amount of the next written value.
128
+ *
129
+ * This can greatly speed up data writes when large files are being written.
130
+ *
131
+ * NOTE: Using ``BiWriter.get`` or ``BiWriter.return`` will now remove all data after the current write position. Use ``BiWriter.data`` to get the full buffer instead.
132
+ */
133
+ extendBufferSize: number;
134
+ /**
135
+ * The settings that used when using the .str getter / setter
136
+ */
137
+ private strDefaults;
138
+ /**
139
+ * Settings for when using .str
140
+ *
141
+ * @param {stringOptions} settings options to use with .str
142
+ */
143
+ set strSettings(settings: stringOptions);
144
+ isBufferOrUint8Array(obj: Buffer | Uint8Array): boolean;
145
+ extendArray(to_padd: number): void;
146
+ /**
147
+ *
148
+ * Change endian, defaults to little.
149
+ *
150
+ * Can be changed at any time, doesn't loose position.
151
+ *
152
+ * @param {endian} endian - endianness ``big`` or ``little``
153
+ */
154
+ endianness(endian: endian): void;
155
+ /**
156
+ * Sets endian to big.
157
+ */
158
+ bigEndian(): void;
159
+ /**
160
+ * Sets endian to big.
161
+ */
162
+ big(): void;
163
+ /**
164
+ * Sets endian to big.
165
+ */
166
+ be(): void;
167
+ /**
168
+ * Sets endian to little.
169
+ */
170
+ littleEndian(): void;
171
+ /**
172
+ * Sets endian to little.
173
+ */
174
+ little(): void;
175
+ /**
176
+ * Sets endian to little.
177
+ */
178
+ le(): void;
179
+ /**
180
+ * Size in bytes of the current buffer.
181
+ *
182
+ * @returns {number} size
183
+ */
184
+ get length(): number;
185
+ /**
186
+ * Size in bytes of the current buffer.
187
+ *
188
+ * @returns {number} size
189
+ */
190
+ get len(): number;
191
+ /**
192
+ * Size in bytes of the current buffer.
193
+ *
194
+ * @returns {number} size
195
+ */
196
+ get FileSize(): number;
197
+ /**
198
+ * Size in bits of the current buffer.
199
+ *
200
+ * @returns {number} size
201
+ */
202
+ get lengthB(): number;
203
+ /**
204
+ * Size in bits of the current buffer.
205
+ *
206
+ * @returns {number} size
207
+ */
208
+ get FileSizeB(): number;
209
+ /**
210
+ * Size in bits of the current buffer.
211
+ *
212
+ * @returns {number} size
213
+ */
214
+ get lenb(): number;
215
+ /**
216
+ * Get the current byte position.
217
+ *
218
+ * @return {number} current byte position
219
+ */
220
+ get tell(): number;
221
+ /**
222
+ * Get the current byte position.
223
+ *
224
+ * @return {number} current byte position
225
+ */
226
+ get FTell(): number;
227
+ /**
228
+ * Get the current byte position.
229
+ *
230
+ * @return {number} current byte position
231
+ */
232
+ get getOffset(): number;
233
+ /**
234
+ * Get the current byte position;
235
+ *
236
+ * @return {number} current byte position
237
+ */
238
+ get saveOffset(): number;
239
+ /**
240
+ * Get the current byte position;
241
+ *
242
+ * @return {number} current byte position
243
+ */
244
+ get off(): number;
245
+ /**
246
+ * Get the current bit position (0-7).
247
+ *
248
+ * @return {number} current bit position
249
+ */
250
+ get getOffsetBit(): number;
251
+ /**
252
+ * Get the current bit position (0-7).
253
+ *
254
+ * @return {number} current bit position
255
+ */
256
+ get tellB(): number;
257
+ /**
258
+ * Get the current bit position (0-7).
259
+ *
260
+ * @return {number} current bit position
261
+ */
262
+ get FTellB(): number;
263
+ /**
264
+ * Get the current bit position (0-7).
265
+ *
266
+ * @return {number} current bit position
267
+ */
268
+ get offb(): number;
269
+ /**
270
+ * Get the current absolute bit position (from start of data).
271
+ *
272
+ * @return {number} current absolute bit position
273
+ */
274
+ get getOffsetAbsBit(): number;
275
+ /**
276
+ * Get the current absolute bit position (from start of data).
277
+ *
278
+ * @return {number} current bit position
279
+ */
280
+ get saveOffsetAbsBit(): number;
281
+ /**
282
+ * Get the current absolute bit position (from start of data).
283
+ *
284
+ * @return {number} current absolute bit position
285
+ */
286
+ get tellAbsB(): number;
287
+ /**
288
+ * Get the current absolute bit position (from start of data).
289
+ *
290
+ * @return {number} current absolute bit position
291
+ */
292
+ get saveOffsetBit(): number;
293
+ /**
294
+ * Get the current absolute bit position (from start of data).
295
+ *
296
+ * @return {number} current absolute bit position
297
+ */
298
+ get offab(): number;
299
+ /**
300
+ * Size in bytes of current read position to the end
301
+ *
302
+ * @returns {number} size
303
+ */
304
+ get remain(): number;
305
+ /**
306
+ * Size in bytes of current read position to the end
307
+ *
308
+ * @returns {number} size
309
+ */
310
+ get FEoF(): number;
311
+ /**
312
+ * Size in bits of current read position to the end
313
+ *
314
+ * @returns {number} size
315
+ */
316
+ get remainB(): number;
317
+ /**
318
+ * Size in bits of current read position to the end
319
+ *
320
+ * @returns {number} size
321
+ */
322
+ get FEoFB(): number;
323
+ /**
324
+ * Row line of the file (16 bytes per row).
325
+ *
326
+ * @returns {number} size
327
+ */
328
+ get getLine(): number;
329
+ /**
330
+ * Row line of the file (16 bytes per row).
331
+ *
332
+ * @returns {number} size
333
+ */
334
+ get row(): number;
335
+ /**
336
+ * Returns current data.
337
+ *
338
+ * Note: Will remove all data after current position if ``extendBufferSize`` was set.
339
+ *
340
+ * Use ``.data`` instead if you want the full buffer data.
341
+ *
342
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
343
+ */
344
+ get get(): Buffer | Uint8Array;
345
+ /**
346
+ * Returns current data.
347
+ *
348
+ * Note: Will remove all data after current position if ``extendBufferSize`` was set.
349
+ *
350
+ * Use ``.data`` instead if you want the full buffer data.
351
+ *
352
+ * @returns {Buffer|Uint8Array} ``Buffer`` or ``Uint8Array``
353
+ */
354
+ get return(): Buffer | Uint8Array;
355
+ /**
356
+ * Creates hex dump string. Will console log or return string if set in options.
357
+ *
358
+ * @param {object} options
359
+ * @param {hexdumpOptions?} options - hex dump options
360
+ * @param {number?} options.length - number of bytes to log, default ``192`` or end of data
361
+ * @param {number?} options.startByte - byte to start dump (default ``0``)
362
+ * @param {boolean?} options.supressUnicode - Supress unicode character preview for even columns.
363
+ * @param {boolean?} options.returnString - Returns the hex dump string instead of logging it.
364
+ */
365
+ hexdump(options?: hexdumpOptions): void | string;
366
+ /**
367
+ * Turn hexdump on error off (default on).
368
+ */
369
+ errorDumpOff(): void;
370
+ /**
371
+ * Turn hexdump on error on (default on).
372
+ */
373
+ errorDumpOn(): void;
374
+ /**
375
+ * Disallows extending data if position is outside of max size.
376
+ */
377
+ restrict(): void;
378
+ /**
379
+ * Allows extending data if position is outside of max size.
380
+ */
381
+ unrestrict(): void;
382
+ /**
383
+ * removes data.
384
+ */
385
+ end(): void;
386
+ /**
387
+ * removes data.
388
+ */
389
+ close(): void;
390
+ /**
391
+ * removes data.
392
+ */
393
+ done(): void;
394
+ /**
395
+ * removes data.
396
+ */
397
+ finished(): void;
398
+ /**
399
+ * Searches for byte position of string from current read position.
400
+ *
401
+ * Returns -1 if not found.
402
+ *
403
+ * Does not change current read position.
404
+ *
405
+ * @param {string} string - String to search for.
406
+ */
407
+ findString(string: string): number;
408
+ /**
409
+ * Searches for byte value (can be signed or unsigned) position from current read position.
410
+ *
411
+ * Returns -1 if not found.
412
+ *
413
+ * Does not change current read position.
414
+ *
415
+ * @param {number} value - Number to search for.
416
+ * @param {boolean} unsigned - If the number is unsigned (default true)
417
+ * @param {endian} endian - endianness of value (default set endian).
418
+ */
419
+ findByte(value: number, unsigned?: boolean, endian?: endian): number;
420
+ /**
421
+ * Searches for short value (can be signed or unsigned) position from current read position.
422
+ *
423
+ * Returns -1 if not found.
424
+ *
425
+ * Does not change current read position.
426
+ *
427
+ * @param {number} value - Number to search for.
428
+ * @param {boolean} unsigned - If the number is unsigned (default true)
429
+ * @param {endian} endian - endianness of value (default set endian).
430
+ */
431
+ findShort(value: number, unsigned?: boolean, endian?: endian): number;
432
+ /**
433
+ * Searches for integer value (can be signed or unsigned) position from current read position.
434
+ *
435
+ * Returns -1 if not found.
436
+ *
437
+ * Does not change current read position.
438
+ *
439
+ * @param {number} value - Number to search for.
440
+ * @param {boolean} unsigned - If the number is unsigned (default true)
441
+ * @param {endian} endian - endianness of value (default set endian).
442
+ */
443
+ findInt(value: number, unsigned?: boolean, endian?: endian): number;
444
+ /**
445
+ * Searches for 64 bit value (can be signed or unsigned) position from current read position.
446
+ *
447
+ * Returns -1 if not found.
448
+ *
449
+ * Does not change current read position.
450
+ *
451
+ * @param {number} value - Number to search for.
452
+ * @param {boolean} unsigned - If the number is unsigned (default true)
453
+ * @param {endian} endian - endianness of value (default set endian).
454
+ */
455
+ findInt64(value: number, unsigned?: boolean, endian?: endian): number;
456
+ /**
457
+ * Searches for half float value position from current read position.
458
+ *
459
+ * Returns -1 if not found.
460
+ *
461
+ * Does not change current read position.
462
+ *
463
+ * @param {number} value - Number to search for.
464
+ * @param {endian} endian - endianness of value (default set endian).
465
+ */
466
+ findHalfFloat(value: number, endian?: endian): number;
467
+ /**
468
+ * Searches for float value position from current read position.
469
+ *
470
+ * Returns -1 if not found.
471
+ *
472
+ * Does not change current read position.
473
+ *
474
+ * @param {number} value - Number to search for.
475
+ * @param {endian} endian - endianness of value (default set endian).
476
+ */
477
+ findFloat(value: number, endian?: endian): number;
478
+ /**
479
+ * Searches for double float value position from current read position.
480
+ *
481
+ * Returns -1 if not found.
482
+ *
483
+ * Does not change current read position.
484
+ *
485
+ * @param {number} value - Number to search for.
486
+ * @param {endian} endian - endianness of value (default set endian).
487
+ */
488
+ findDoubleFloat(value: number, endian?: endian): number;
489
+ /**
490
+ * Aligns current byte position.
491
+ *
492
+ * Note: Will extend array if strict mode is off and outside of max size.
493
+ *
494
+ * @param {number} number - Byte to align
495
+ */
496
+ align(number: number): void;
497
+ /**
498
+ * Reverse aligns current byte position.
499
+ *
500
+ * Note: Will extend array if strict mode is off and outside of max size.
501
+ *
502
+ * @param {number} number - Byte to align
503
+ */
504
+ alignRev(number: number): void;
505
+ /**
506
+ * Offset current byte or bit position.
507
+ *
508
+ * Note: Will extend array if strict mode is off and outside of max size.
509
+ *
510
+ * @param {number} bytes - Bytes to skip
511
+ * @param {number} bits - Bits to skip
512
+ */
513
+ skip(bytes: number, bits?: number): void;
514
+ /**
515
+ * Offset current byte or bit position.
516
+ *
517
+ * Note: Will extend array if strict mode is off and outside of max size.
518
+ *
519
+ * @param {number} bytes - Bytes to skip
520
+ * @param {number} bits - Bits to skip
521
+ */
522
+ jump(bytes: number, bits?: number): void;
523
+ /**
524
+ * Change position directly to address.
525
+ *
526
+ * Note: Will extend array if strict mode is off and outside of max size.
527
+ *
528
+ * @param {number} byte - byte to set to
529
+ * @param {number} bit - bit to set to
530
+ */
531
+ FSeek(byte: number, bit?: number): void;
532
+ /**
533
+ * Offset current byte or bit position.
534
+ *
535
+ * Note: Will extend array if strict mode is off and outside of max size.
536
+ *
537
+ * @param {number} bytes - Bytes to skip
538
+ * @param {number} bits - Bits to skip
539
+ */
540
+ seek(bytes: number, bits?: number): void;
541
+ /**
542
+ * Change position directly to address.
543
+ *
544
+ * Note: Will extend array if strict mode is off and outside of max size.
545
+ *
546
+ * @param {number} byte - byte to set to
547
+ * @param {number} bit - bit to set to
548
+ */
549
+ goto(byte: number, bit?: number): void;
550
+ /**
551
+ * Change position directly to address.
552
+ *
553
+ * Note: Will extend array if strict mode is off and outside of max size.
554
+ *
555
+ * @param {number} byte - byte to set to
556
+ * @param {number} bit - bit to set to
557
+ */
558
+ pointer(byte: number, bit?: number): void;
559
+ /**
560
+ * Change position directly to address.
561
+ *
562
+ * Note: Will extend array if strict mode is off and outside of max size.
563
+ *
564
+ * @param {number} byte - byte to set to
565
+ * @param {number} bit - bit to set to
566
+ */
567
+ warp(byte: number, bit?: number): void;
568
+ /**
569
+ * Set byte and bit position to start of data.
570
+ */
571
+ rewind(): void;
572
+ /**
573
+ * Set byte and bit position to start of data.
574
+ */
575
+ gotoStart(): void;
576
+ /**
577
+ * Set current byte and bit position to end of data.
578
+ */
579
+ last(): void;
580
+ /**
581
+ * Set current byte and bit position to end of data.
582
+ */
583
+ gotoEnd(): void;
584
+ /**
585
+ * Set byte and bit position to start of data.
586
+ */
587
+ EoF(): void;
588
+ /**
589
+ * Deletes part of data from start to current byte position unless supplied, returns removed.
590
+ *
591
+ * Note: Errors in strict mode.
592
+ *
593
+ * @param {number} startOffset - Start location (default 0)
594
+ * @param {number} endOffset - End location (default current position)
595
+ * @param {boolean} consume - Move position to end of removed data (default false)
596
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
597
+ */
598
+ delete(startOffset?: number, endOffset?: number, consume?: boolean): Buffer | Uint8Array;
599
+ /**
600
+ * Deletes part of data from current byte position to end, returns removed.
601
+ *
602
+ * Note: Errors in strict mode.
603
+ *
604
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
605
+ */
606
+ clip(): Buffer | Uint8Array;
607
+ /**
608
+ * Deletes part of data from current byte position to end, returns removed.
609
+ *
610
+ * Note: Errors in strict mode.
611
+ *
612
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
613
+ */
614
+ trim(): Buffer | Uint8Array;
615
+ /**
616
+ * Deletes part of data from current byte position to supplied length, returns removed.
617
+ *
618
+ * Note: Errors in strict mode.
619
+ *
620
+ * @param {number} length - Length of data in bytes to remove
621
+ * @param {boolean} consume - Move position to end of removed data (default false)
622
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
623
+ */
624
+ crop(length: number, consume?: boolean): Buffer | Uint8Array;
625
+ /**
626
+ * Deletes part of data from current position to supplied length, returns removed.
627
+ *
628
+ * Note: Only works in strict mode.
629
+ *
630
+ * @param {number} length - Length of data in bytes to remove
631
+ * @param {boolean} consume - Move position to end of removed data (default false)
632
+ * @returns {Buffer|Uint8Array} Removed data as ``Buffer`` or ``Uint8Array``
633
+ */
634
+ drop(length: number, consume?: boolean): Buffer | Uint8Array;
635
+ /**
636
+ * Replaces data in data.
637
+ *
638
+ * Note: Errors on strict mode.
639
+ *
640
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
641
+ * @param {boolean} consume - Move current byte position to end of data (default false)
642
+ * @param {number} offset - Offset to add it at (defaults to current position)
643
+ */
644
+ replace(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
645
+ /**
646
+ * Replaces data in data.
647
+ *
648
+ * Note: Errors on strict mode.
649
+ *
650
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
651
+ * @param {boolean} consume - Move current byte position to end of data (default false)
652
+ * @param {number} offset - Offset to add it at (defaults to current position)
653
+ */
654
+ overwrite(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
655
+ /**
656
+ * Returns part of data from current byte position to end of data unless supplied.
657
+ *
658
+ * @param {number} startOffset - Start location (default current position)
659
+ * @param {number} endOffset - End location (default end of data)
660
+ * @param {boolean} consume - Move position to end of lifted data (default false)
661
+ * @param {number} fillValue - Byte value to to fill returned data (does NOT fill unless supplied)
662
+ * @returns {Buffer|Uint8Array} Selected data as ``Uint8Array`` or ``Buffer``
663
+ */
664
+ lift(startOffset?: number, endOffset?: number, consume?: boolean, fillValue?: number): Buffer | Uint8Array;
665
+ /**
666
+ * Returns part of data from current byte position to end of data unless supplied.
667
+ *
668
+ * @param {number} startOffset - Start location (default current position)
669
+ * @param {number} endOffset - End location (default end of data)
670
+ * @param {boolean} consume - Move position to end of lifted data (default false)
671
+ * @param {number} fillValue - Byte value to to fill returned data (does NOT fill unless supplied)
672
+ * @returns {Buffer|Uint8Array} Selected data as ``Uint8Array`` or ``Buffer``
673
+ */
674
+ fill(startOffset?: number, endOffset?: number, consume?: boolean, fillValue?: number): Buffer | Uint8Array;
675
+ /**
676
+ * Extract data from current position to length supplied.
677
+ *
678
+ * Note: Does not affect supplied data.
679
+ *
680
+ * @param {number} length - Length of data in bytes to copy from current offset
681
+ * @param {number} consume - Moves offset to end of length
682
+ * @returns {Buffer|Uint8Array} Selected data as ``Uint8Array`` or ``Buffer``
683
+ */
684
+ extract(length: number, consume?: boolean): Buffer | Uint8Array;
685
+ /**
686
+ * Extract data from current position to length supplied.
687
+ *
688
+ * Note: Does not affect supplied data.
689
+ *
690
+ * @param {number} length - Length of data in bytes to copy from current offset
691
+ * @param {number} consume - Moves offset to end of length
692
+ * @returns {Buffer|Uint8Array} Selected data as ``Uint8Array`` or ``Buffer``
693
+ */
694
+ slice(length: number, consume?: boolean): Buffer | Uint8Array;
695
+ /**
696
+ * Extract data from current position to length supplied.
697
+ *
698
+ * Note: Does not affect supplied data.
699
+ *
700
+ * @param {number} length - Length of data in bytes to copy from current offset
701
+ * @param {number} consume - Moves offset to end of length
702
+ * @returns {Buffer|Uint8Array} Selected data as ``Uint8Array`` or ``Buffer``
703
+ */
704
+ wrap(length: number, consume?: boolean): Buffer | Uint8Array;
705
+ /**
706
+ * Inserts data into data.
707
+ *
708
+ * Note: Errors on strict mode.
709
+ *
710
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
711
+ * @param {boolean} consume - Move current byte position to end of data (default false)
712
+ * @param {number} offset - Byte position to add at (defaults to current position)
713
+ */
714
+ insert(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
715
+ /**
716
+ * Inserts data into data.
717
+ *
718
+ * Note: Errors on strict mode.
719
+ *
720
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
721
+ * @param {boolean} consume - Move current byte position to end of data (default false)
722
+ * @param {number} offset - Byte position to add at (defaults to current position)
723
+ */
724
+ place(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
725
+ /**
726
+ * Adds data to start of supplied data.
727
+ *
728
+ * Note: Errors on strict mode.
729
+ *
730
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
731
+ * @param {boolean} consume - Move current write position to end of data (default false)
732
+ */
733
+ unshift(data: Buffer | Uint8Array, consume?: boolean): void;
734
+ /**
735
+ * Adds data to start of supplied data.
736
+ *
737
+ * Note: Errors on strict mode.
738
+ *
739
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
740
+ * @param {boolean} consume - Move current write position to end of data (default false)
741
+ */
742
+ prepend(data: Buffer | Uint8Array, consume?: boolean): void;
743
+ /**
744
+ * Adds data to end of supplied data.
745
+ *
746
+ * Note: Errors on strict mode.
747
+ *
748
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
749
+ * @param {boolean} consume - Move current write position to end of data (default false)
750
+ */
751
+ push(data: Buffer | Uint8Array, consume?: boolean): void;
752
+ /**
753
+ * Adds data to end of supplied data.
754
+ *
755
+ * Note: Errors on strict mode.
756
+ *
757
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
758
+ * @param {boolean} consume - Move current write position to end of data (default false)
759
+ */
760
+ append(data: Buffer | Uint8Array, consume?: boolean): void;
761
+ /**
762
+ * XOR data.
763
+ *
764
+ * @param {number|string|Uint8Array|Buffer} xorKey - Value, string or array to XOR
765
+ * @param {number} startOffset - Start location (default current byte position)
766
+ * @param {number} endOffset - End location (default end of data)
767
+ * @param {boolean} consume - Move current position to end of data (default false)
768
+ */
769
+ xor(xorKey: number | string | Uint8Array | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
770
+ /**
771
+ * XOR data.
772
+ *
773
+ * @param {number|string|Uint8Array|Buffer} xorKey - Value, string or array to XOR
774
+ * @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)
775
+ * @param {boolean} consume - Move current position to end of data (default false)
776
+ */
777
+ xorThis(xorKey: number | string | Uint8Array | Buffer, length?: number, consume?: boolean): void;
778
+ /**
779
+ * OR data
780
+ *
781
+ * @param {number|string|Uint8Array|Buffer} orKey - Value, string or array to OR
782
+ * @param {number} startOffset - Start location (default current byte position)
783
+ * @param {number} endOffset - End location (default end of data)
784
+ * @param {boolean} consume - Move current position to end of data (default false)
785
+ */
786
+ or(orKey: number | string | Uint8Array | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
787
+ /**
788
+ * OR data.
789
+ *
790
+ * @param {number|string|Uint8Array|Buffer} orKey - Value, string or array to OR
791
+ * @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)
792
+ * @param {boolean} consume - Move current position to end of data (default false)
793
+ */
794
+ orThis(orKey: number | string | Uint8Array | Buffer, length?: number, consume?: boolean): void;
795
+ /**
796
+ * AND data.
797
+ *
798
+ * @param {number|string|Array<number>|Buffer} andKey - Value, string or array to AND
799
+ * @param {number} startOffset - Start location (default current byte position)
800
+ * @param {number} endOffset - End location (default end of data)
801
+ * @param {boolean} consume - Move current position to end of data (default false)
802
+ */
803
+ and(andKey: number | string | Array<number> | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
804
+ /**
805
+ * AND data.
806
+ *
807
+ * @param {number|string|Array<number>|Buffer} andKey - Value, string or array to AND
808
+ * @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)
809
+ * @param {boolean} consume - Move current position to end of data (default false)
810
+ */
811
+ andThis(andKey: number | string | Array<number> | Buffer, length?: number, consume?: boolean): void;
812
+ /**
813
+ * Add value to data.
814
+ *
815
+ * @param {number|string|Array<number>|Buffer} addKey - Value, string or array to add to data
816
+ * @param {number} startOffset - Start location (default current byte position)
817
+ * @param {number} endOffset - End location (default end of data)
818
+ * @param {boolean} consume - Move current position to end of data (default false)
819
+ */
820
+ add(addKey: number | string | Array<number> | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
821
+ /**
822
+ * Add value to data.
823
+ *
824
+ * @param {number|string|Array<number>|Buffer} addKey - Value, string or array to add to data
825
+ * @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)
826
+ * @param {boolean} consume - Move current position to end of data (default false)
827
+ */
828
+ addThis(addKey: number | string | Array<number> | Buffer, length?: number, consume?: boolean): void;
829
+ /**
830
+ * Not data.
831
+ *
832
+ * @param {number} startOffset - Start location (default current byte position)
833
+ * @param {number} endOffset - End location (default end of data)
834
+ * @param {boolean} consume - Move current position to end of data (default false)
835
+ */
836
+ not(startOffset?: number, endOffset?: number, consume?: boolean): void;
837
+ /**
838
+ * Not data.
839
+ *
840
+ * @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)
841
+ * @param {boolean} consume - Move current position to end of data (default false)
842
+ */
843
+ notThis(length?: number, consume?: boolean): void;
844
+ /**
845
+ * Left shift data.
846
+ *
847
+ * @param {number|string|Array<number>|Buffer} shiftKey - Value, string or array to left shift data
848
+ * @param {number} startOffset - Start location (default current byte position)
849
+ * @param {number} endOffset - End location (default end of data)
850
+ * @param {boolean} consume - Move current position to end of data (default false)
851
+ */
852
+ lShift(shiftKey: number | string | Array<number> | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
853
+ /**
854
+ * Left shift data.
855
+ *
856
+ * @param {number|string|Array<number>|Buffer} shiftKey - Value, string or array to left shift data
857
+ * @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)
858
+ * @param {boolean} consume - Move current position to end of data (default false)
859
+ */
860
+ lShiftThis(shiftKey: number | string | Array<number> | Buffer, length?: number, consume?: boolean): void;
861
+ /**
862
+ * Right shift data.
863
+ *
864
+ * @param {number|string|Array<number>|Buffer} shiftKey - Value, string or array to right shift data
865
+ * @param {number} startOffset - Start location (default current byte position)
866
+ * @param {number} endOffset - End location (default end of data)
867
+ * @param {boolean} consume - Move current position to end of data (default false)
868
+ */
869
+ rShift(shiftKey: number | string | Array<number> | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
870
+ /**
871
+ * Right shift data.
872
+ *
873
+ * @param {number|string|Array<number>|Buffer} shiftKey - Value, string or array to right shift data
874
+ * @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)
875
+ * @param {boolean} consume - Move current position to end of data (default false)
876
+ */
877
+ rShiftThis(shiftKey: number | string | Array<number> | Buffer, length?: number, consume?: boolean): void;
878
+ /**
879
+ *
880
+ * Write bits, must have at least value and number of bits.
881
+ *
882
+ * ``Note``: When returning to a byte write, remaining bits are skipped.
883
+ *
884
+ * @param {number} value - value as int
885
+ * @param {number} bits - number of bits to write
886
+ * @param {boolean} unsigned - if value is unsigned
887
+ * @param {endian} endian - ``big`` or ``little``
888
+ */
889
+ writeBit(value: number, bits: number, unsigned?: boolean, endian?: endian): void;
890
+ /**
891
+ * Bit field writer.
892
+ *
893
+ * Note: When returning to a byte write, remaining bits are dropped.
894
+ *
895
+ * @param {number} value - value as int
896
+ * @param {number} bits - bits to write
897
+ * @returns number
898
+ */
899
+ writeUBitBE(value: number, bits: number): void;
900
+ /**
901
+ * Bit field writer.
902
+ *
903
+ * Note: When returning to a byte write, remaining bits are dropped.
904
+ *
905
+ * @param {number} value - value as int
906
+ * @param {number} bits - bits to write
907
+ * @param {boolean} unsigned - if the value is unsigned
908
+ * @returns number
909
+ */
910
+ writeBitBE(value: number, bits: number, unsigned?: boolean): void;
911
+ /**
912
+ * Bit field writer.
913
+ *
914
+ * Note: When returning to a byte write, remaining bits are dropped.
915
+ *
916
+ * @param {number} value - value as int
917
+ * @param {number} bits - bits to write
918
+ * @returns number
919
+ */
920
+ writeUBitLE(value: number, bits: number): void;
921
+ /**
922
+ * Bit field writer.
923
+ *
924
+ * Note: When returning to a byte write, remaining bits are dropped.
925
+ *
926
+ * @param {number} value - value as int
927
+ * @param {number} bits - bits to write
928
+ * @param {boolean} unsigned - if the value is unsigned
929
+ * @returns number
930
+ */
931
+ writeBitLE(value: number, bits: number, unsigned?: boolean): void;
932
+ /**
933
+ * Bit field reader.
934
+ *
935
+ * Note: When returning to a byte read, remaining bits are dropped.
936
+ *
937
+ * @param {number} bits - bits to read
938
+ * @param {boolean} unsigned - if the value is unsigned
939
+ * @param {endian} endian - ``big`` or ``little``
940
+ * @returns {number}
941
+ */
942
+ readBit(bits?: number, unsigned?: boolean, endian?: endian): number;
943
+ /**
944
+ * Bit field reader.
945
+ *
946
+ * Note: When returning to a byte read, remaining bits are dropped.
947
+ *
948
+ * @param {number} bits - bits to read
949
+ * @returns {number}
950
+ */
951
+ readUBitBE(bits: number): number;
952
+ /**
953
+ * Bit field reader.
954
+ *
955
+ * Note: When returning to a byte read, remaining bits are dropped.
956
+ *
957
+ * @param {number} bits - bits to read
958
+ * @param {boolean} unsigned - if the value is unsigned
959
+ * @returns {number}
960
+ */
961
+ readBitBE(bits: number, unsigned?: boolean): number;
962
+ /**
963
+ * Bit field reader.
964
+ *
965
+ * Note: When returning to a byte read, remaining bits are dropped.
966
+ *
967
+ * @param {number} bits - bits to read
968
+ * @returns {number}
969
+ */
970
+ readUBitLE(bits: number): number;
971
+ /**
972
+ * Bit field reader.
973
+ *
974
+ * Note: When returning to a byte read, remaining bits are dropped.
975
+ *
976
+ * @param {number} bits - bits to read
977
+ * @param {boolean} unsigned - if the value is unsigned
978
+ * @returns {number}
979
+ */
980
+ readBitLE(bits: number, unsigned?: boolean): number;
981
+ /**
982
+ * Read byte.
983
+ *
984
+ * @param {boolean} unsigned - if value is unsigned or not
985
+ * @returns {number}
986
+ */
987
+ readByte(unsigned?: boolean): number;
988
+ /**
989
+ * Read multiple bytes.
990
+ *
991
+ * @param {number} amount - amount of bytes to read
992
+ * @param {boolean} unsigned - if value is unsigned or not
993
+ * @returns {number[]}
994
+ */
995
+ readBytes(amount: number, unsigned?: boolean): number[];
996
+ /**
997
+ * Write byte.
998
+ *
999
+ * @param {number} value - value as int
1000
+ * @param {boolean} unsigned - if the value is unsigned
1001
+ */
1002
+ writeByte(value: number, unsigned?: boolean): void;
1003
+ /**
1004
+ * Write multiple bytes.
1005
+ *
1006
+ * @param {number[]} values - array of values as int
1007
+ * @param {boolean} unsigned - if the value is unsigned
1008
+ */
1009
+ writeBytes(values: number[], unsigned?: boolean): void;
1010
+ /**
1011
+ * Write unsigned byte.
1012
+ *
1013
+ * @param {number} value - value as int
1014
+ */
1015
+ writeUByte(value: number): void;
1016
+ /**
1017
+ * Read unsigned byte.
1018
+ *
1019
+ * @returns {number}
1020
+ */
1021
+ readUByte(): number;
1022
+ /**
1023
+ * Read short.
1024
+ *
1025
+ * @param {boolean} unsigned - if value is unsigned or not
1026
+ * @param {endian} endian - ``big`` or ``little``
1027
+ * @returns {number}
1028
+ */
1029
+ readInt16(unsigned?: boolean, endian?: endian): number;
1030
+ /**
1031
+ * Write int16.
1032
+ *
1033
+ * @param {number} value - value as int
1034
+ * @param {boolean} unsigned - if the value is unsigned
1035
+ * @param {endian} endian - ``big`` or ``little``
1036
+ */
1037
+ writeInt16(value: number, unsigned?: boolean, endian?: endian): void;
1038
+ /**
1039
+ * Write unsigned int16.
1040
+ *
1041
+ * @param {number} value - value as int
1042
+ * @param {endian} endian - ``big`` or ``little``
1043
+ */
1044
+ writeUInt16(value: number, endian?: endian): void;
1045
+ /**
1046
+ * Write unsigned int16.
1047
+ *
1048
+ * @param {number} value - value as int
1049
+ */
1050
+ writeUInt16BE(value: number): void;
1051
+ /**
1052
+ * Write unsigned int16.
1053
+ *
1054
+ * @param {number} value - value as int
1055
+ */
1056
+ writeUInt16LE(value: number): void;
1057
+ /**
1058
+ * Write signed int16.
1059
+ *
1060
+ * @param {number} value - value as int
1061
+ */
1062
+ writeInt16LE(value: number): void;
1063
+ /**
1064
+ * Read unsigned short.
1065
+ *
1066
+ * @param {endian} endian - ``big`` or ``little``
1067
+ *
1068
+ * @returns {number}
1069
+ */
1070
+ readUInt16(endian?: endian): number;
1071
+ /**
1072
+ * Read unsigned short in little endian.
1073
+ *
1074
+ * @returns {number}
1075
+ */
1076
+ readUInt16LE(): number;
1077
+ /**
1078
+ * Read signed short in little endian.
1079
+ *
1080
+ * @returns {number}
1081
+ */
1082
+ readInt16LE(): number;
1083
+ /**
1084
+ * Read unsigned short in big endian.
1085
+ *
1086
+ * @returns {number}
1087
+ */
1088
+ readUInt16BE(): number;
1089
+ /**
1090
+ * Read signed short in big endian.
1091
+ *
1092
+ * @returns {number}
1093
+ */
1094
+ readInt16BE(): number;
1095
+ /**
1096
+ * Read half float.
1097
+ *
1098
+ * @param {endian} endian - ``big`` or ``little``
1099
+ * @returns {number}
1100
+ */
1101
+ readHalfFloat(endian?: endian): number;
1102
+ /**
1103
+ * Writes half float.
1104
+ *
1105
+ * @param {number} value - value as int
1106
+ * @param {endian} endian - ``big`` or ``little``
1107
+ */
1108
+ writeHalfFloat(value: number, endian?: endian): void;
1109
+ /**
1110
+ * Writes half float.
1111
+ *
1112
+ * @param {number} value - value as int
1113
+ */
1114
+ writeHalfFloatBE(value: number): void;
1115
+ /**
1116
+ * Writes half float.
1117
+ *
1118
+ * @param {number} value - value as int
1119
+ */
1120
+ writeHalfFloatLE(value: number): void;
1121
+ /**
1122
+ * Read half float.
1123
+ *
1124
+ * @returns {number}
1125
+ */
1126
+ readHalfFloatBE(): number;
1127
+ /**
1128
+ * Read half float.
1129
+ *
1130
+ * @returns {number}
1131
+ */
1132
+ readHalfFloatLE(): number;
1133
+ /**
1134
+ * Read 32 bit integer.
1135
+ *
1136
+ * @param {boolean} unsigned - if value is unsigned or not
1137
+ * @param {endian} endian - ``big`` or ``little``
1138
+ * @returns {number}
1139
+ */
1140
+ readInt32(unsigned?: boolean, endian?: endian): number;
1141
+ /**
1142
+ * Write int32.
1143
+ *
1144
+ * @param {number} value - value as int
1145
+ * @param {boolean} unsigned - if the value is unsigned
1146
+ * @param {endian} endian - ``big`` or ``little``
1147
+ */
1148
+ writeInt32(value: number, unsigned?: boolean, endian?: endian): void;
1149
+ /**
1150
+ * Write unsigned int32.
1151
+ *
1152
+ * @param {number} value - value as int
1153
+ * @param {endian} endian - ``big`` or ``little``
1154
+ */
1155
+ writeUInt32(value: number, endian?: endian): void;
1156
+ /**
1157
+ * Write signed int32.
1158
+ *
1159
+ * @param {number} value - value as int
1160
+ */
1161
+ writeInt32LE(value: number): void;
1162
+ /**
1163
+ * Write unsigned int32.
1164
+ *
1165
+ * @param {number} value - value as int
1166
+ */
1167
+ writeUInt32LE(value: number): void;
1168
+ /**
1169
+ * Write signed int32.
1170
+ *
1171
+ * @param {number} value - value as int
1172
+ */
1173
+ writeInt32BE(value: number): void;
1174
+ /**
1175
+ * Read signed 32 bit integer.
1176
+ *
1177
+ * @returns {number}
1178
+ */
1179
+ readInt32BE(): number;
1180
+ /**
1181
+ * Read unsigned 32 bit integer.
1182
+ *
1183
+ * @returns {number}
1184
+ */
1185
+ readUInt32BE(): number;
1186
+ /**
1187
+ * Read signed 32 bit integer.
1188
+ *
1189
+ * @returns {number}
1190
+ */
1191
+ readInt32LE(): number;
1192
+ /**
1193
+ * Read signed 32 bit integer.
1194
+ *
1195
+ * @returns {number}
1196
+ */
1197
+ readUInt32LE(): number;
1198
+ /**
1199
+ * Read unsigned 32 bit integer.
1200
+ *
1201
+ * @returns {number}
1202
+ */
1203
+ readUInt(): number;
1204
+ /**
1205
+ * Read float.
1206
+ *
1207
+ * @param {endian} endian - ``big`` or ``little``
1208
+ * @returns {number}
1209
+ */
1210
+ readFloat(endian?: endian): number;
1211
+ /**
1212
+ * Write float.
1213
+ *
1214
+ * @param {number} value - value as int
1215
+ * @param {endian} endian - ``big`` or ``little``
1216
+ */
1217
+ writeFloat(value: number, endian?: endian): void;
1218
+ /**
1219
+ * Write float.
1220
+ *
1221
+ * @param {number} value - value as int
1222
+ */
1223
+ writeFloatLE(value: number): void;
1224
+ /**
1225
+ * Write float.
1226
+ *
1227
+ * @param {number} value - value as int
1228
+ */
1229
+ writeFloatBE(value: number): void;
1230
+ /**
1231
+ * Read float.
1232
+ *
1233
+ * @returns {number}
1234
+ */
1235
+ readFloatBE(): number;
1236
+ /**
1237
+ * Read float.
1238
+ *
1239
+ * @returns {number}
1240
+ */
1241
+ readFloatLE(): number;
1242
+ /**
1243
+ * Read signed 64 bit integer.
1244
+ *
1245
+ * @param {boolean} unsigned - if value is unsigned or not
1246
+ * @param {endian?} endian - ``big`` or ``little``
1247
+ * @returns {number}
1248
+ */
1249
+ readInt64(unsigned?: boolean, endian?: endian): bigint;
1250
+ /**
1251
+ * Write 64 bit integer.
1252
+ *
1253
+ * @param {number} value - value as int
1254
+ * @param {boolean} unsigned - if the value is unsigned
1255
+ * @param {endian} endian - ``big`` or ``little``
1256
+ */
1257
+ writeInt64(value: number, unsigned?: boolean, endian?: endian): void;
1258
+ /**
1259
+ * Write unsigned 64 bit integer.
1260
+ *
1261
+ * @param {number} value - value as int
1262
+ * @param {endian} endian - ``big`` or ``little``
1263
+ */
1264
+ writeUInt64(value: number, endian?: endian): void;
1265
+ /**
1266
+ * Write signed 64 bit integer.
1267
+ *
1268
+ * @param {number} value - value as int
1269
+ */
1270
+ writeInt64LE(value: number): void;
1271
+ /**
1272
+ * Write unsigned 64 bit integer.
1273
+ *
1274
+ * @param {number} value - value as int
1275
+ */
1276
+ writeUInt64LE(value: number): void;
1277
+ /**
1278
+ * Write signed 64 bit integer.
1279
+ *
1280
+ * @param {number} value - value as int
1281
+ */
1282
+ writeInt64BE(value: number): void;
1283
+ /**
1284
+ * Write unsigned 64 bit integer.
1285
+ *
1286
+ * @param {number} value - value as int
1287
+ */
1288
+ writeUInt64BE(value: number): void;
1289
+ /**
1290
+ * Read unsigned 64 bit integer.
1291
+ *
1292
+ * @returns {number}
1293
+ */
1294
+ readUInt64(): bigint;
1295
+ /**
1296
+ * Read signed 64 bit integer.
1297
+ *
1298
+ * @returns {number}
1299
+ */
1300
+ readInt64BE(): bigint;
1301
+ /**
1302
+ * Read unsigned 64 bit integer.
1303
+ *
1304
+ * @returns {number}
1305
+ */
1306
+ readUInt64BE(): bigint;
1307
+ /**
1308
+ * Read signed 64 bit integer.
1309
+ *
1310
+ * @returns {number}
1311
+ */
1312
+ readInt64LE(): bigint;
1313
+ /**
1314
+ * Read unsigned 64 bit integer.
1315
+ *
1316
+ * @returns {number}
1317
+ */
1318
+ readUInt64LE(): bigint;
1319
+ /**
1320
+ * Read double float.
1321
+ *
1322
+ * @param {endian} endian - ``big`` or ``little``
1323
+ * @returns {number}
1324
+ */
1325
+ readDoubleFloat(endian?: endian): number;
1326
+ /**
1327
+ * Writes double float.
1328
+ *
1329
+ * @param {number} value - value as int
1330
+ * @param {endian} endian - ``big`` or ``little``
1331
+ */
1332
+ writeDoubleFloat(value: number, endian?: endian): void;
1333
+ /**
1334
+ * Writes double float.
1335
+ *
1336
+ * @param {number} value - value as int
1337
+ */
1338
+ writeDoubleFloatBE(value: number): void;
1339
+ /**
1340
+ * Writes double float.
1341
+ *
1342
+ * @param {number} value - value as int
1343
+ */
1344
+ writeDoubleFloatLE(value: number): void;
1345
+ /**
1346
+ * Read double float.
1347
+ *
1348
+ * @returns {number}
1349
+ */
1350
+ readDoubleFloatBE(): number;
1351
+ /**
1352
+ * Read double float.
1353
+ *
1354
+ * @returns {number}
1355
+ */
1356
+ readDoubleFloatLE(): number;
1357
+ /**
1358
+ * Reads string, use options object for different types.
1359
+ *
1360
+ * @param {stringOptions} options
1361
+ * @param {stringOptions["length"]?} options.length - for fixed length, non-terminate value utf strings
1362
+ * @param {stringOptions["stringType"]?} options.stringType - utf-8, utf-16, pascal or wide-pascal
1363
+ * @param {stringOptions["terminateValue"]?} options.terminateValue - only with stringType: "utf"
1364
+ * @param {stringOptions["lengthReadSize"]?} options.lengthReadSize - for pascal strings. 1, 2 or 4 byte length read size
1365
+ * @param {stringOptions["encoding"]?} options.encoding - TextEncoder accepted types
1366
+ * @param {stringOptions["endian"]?} options.endian - for wide-pascal and utf-16
1367
+ * @return {Promise<string>}
1368
+ */
1369
+ readString(options?: stringOptions): string;
1370
+ /**
1371
+ * Writes string, use options object for different types.
1372
+ *
1373
+ * @param {string} string - text string
1374
+ * @param {stringOptions?} options
1375
+ * @param {stringOptions["length"]?} options.length - for fixed length, non-terminate value utf strings
1376
+ * @param {stringOptions["stringType"]?} options.stringType - utf-8, utf-16, pascal or wide-pascal
1377
+ * @param {stringOptions["terminateValue"]?} options.terminateValue - only with stringType: "utf"
1378
+ * @param {stringOptions["lengthWriteSize"]?} options.lengthWriteSize - for pascal strings. 1, 2 or 4 byte length write size
1379
+ * @param {stringOptions["encoding"]?} options.encoding - TextEncoder accepted types
1380
+ * @param {stringOptions["endian"]?} options.endian - for wide-pascal and utf-16
1381
+ */
1382
+ writeString(string: string, options?: stringOptions): void;
1383
+ }
1384
+
1385
+ /**
1386
+ * For file system in Node
1387
+ */
1388
+ type FileDescriptor = number;
1389
+ /**
1390
+ * file system read modes
1391
+ */
1392
+ type fsMode = "w+" | "r";
1393
+ declare class BiBaseStreamer {
1394
+ /**
1395
+ * Endianness of default read.
1396
+ *
1397
+ * @type {endian}
1398
+ */
1399
+ endian: endian;
1400
+ /**
1401
+ * Current read byte location.
1402
+ */
1403
+ offset: number;
1404
+ /**
1405
+ * Current read byte's bit location.
1406
+ */
1407
+ bitoffset: number;
1408
+ /**
1409
+ * Size in bytes of the current file.
1410
+ */
1411
+ size: number;
1412
+ /**
1413
+ * Size in bits of the current file.
1414
+ */
1415
+ sizeB: number;
1416
+ /**
1417
+ * Allows the file to extend reading or writing outside of current size
1418
+ */
1419
+ strict: boolean;
1420
+ /**
1421
+ * Console log a hexdump on error.
1422
+ */
1423
+ errorDump: boolean;
1424
+ /**
1425
+ * Current buffer chunk.
1426
+ *
1427
+ * @type {Buffer}
1428
+ */
1429
+ data: Buffer | null;
1430
+ /**
1431
+ * When the data buffer needs to be extended while strict mode is ``false``, this will be the amount it extends.
1432
+ *
1433
+ * Otherwise it extends just the amount of the next written value.
1434
+ *
1435
+ * This can greatly speed up data writes when large files are being written.
1436
+ *
1437
+ * NOTE: Using ``BiWriter.get`` or ``BiWriter.return`` will now remove all data after the current write position. Use ``BiWriter.data`` to get the full buffer instead.
1438
+ */
1439
+ extendBufferSize: number;
1440
+ fd: FileDescriptor | null;
1441
+ filePath: string;
1442
+ fsMode: fsMode;
1443
+ /**
1444
+ * The settings that used when using the .str getter / setter
1445
+ */
1446
+ private strDefaults;
1447
+ maxFileSize: number | null;
1448
+ constructor(filePath: string, readwrite: boolean);
1449
+ /**
1450
+ * Settings for when using .str
1451
+ *
1452
+ * @param {stringOptions} settings options to use with .str
1453
+ */
1454
+ set strSettings(settings: stringOptions);
1455
+ /**
1456
+ * Enabling write mode in reader.
1457
+ *
1458
+ * @param {boolean} writeMode - Enabling write mode in reader.
1459
+ */
1460
+ writeMode(writeMode: boolean): void;
1461
+ /**
1462
+ * Opens the file. Must be run before reading or writing.
1463
+ *
1464
+ * @returns {number} file size
1465
+ */
1466
+ open(): number;
1467
+ /**
1468
+ * Internal update size
1469
+ */
1470
+ updateSize(): void;
1471
+ /**
1472
+ * Closes the file.
1473
+ *
1474
+ * @returns {void}
1475
+ */
1476
+ close(): void;
1477
+ /**
1478
+ * Internal reader
1479
+ *
1480
+ * @param start - likely this.offset
1481
+ * @param length
1482
+ * @param consume
1483
+ * @returns
1484
+ */
1485
+ read(start: number, length: number, consume?: boolean): Buffer;
1486
+ /**
1487
+ * Internal writer
1488
+ *
1489
+ * @param start - likely this.offset
1490
+ * @param data
1491
+ * @param consume
1492
+ * @returns {number}
1493
+ */
1494
+ write(start: number, data: Buffer, consume?: boolean): number;
1495
+ /**
1496
+ * internal write commit
1497
+ *
1498
+ * @param consume
1499
+ * @returns {number}
1500
+ */
1501
+ commit(consume?: boolean): number;
1502
+ /**
1503
+ * internal extend
1504
+ *
1505
+ *
1506
+ * @param length amount needed
1507
+ * @returns {void}
1508
+ */
1509
+ extendArray(length: number): void;
1510
+ isBufferOrUint8Array(obj: Buffer | Uint8Array): boolean;
1511
+ /**
1512
+ *
1513
+ * Change endian, defaults to little.
1514
+ *
1515
+ * Can be changed at any time, doesn't loose position.
1516
+ *
1517
+ * @param {endian} endian - endianness ``big`` or ``little``
1518
+ */
1519
+ endianness(endian: endian): void;
1520
+ /**
1521
+ * Sets endian to big.
1522
+ */
1523
+ bigEndian(): void;
1524
+ /**
1525
+ * Sets endian to big.
1526
+ */
1527
+ big(): void;
1528
+ /**
1529
+ * Sets endian to big.
1530
+ */
1531
+ be(): void;
1532
+ /**
1533
+ * Sets endian to little.
1534
+ */
1535
+ littleEndian(): void;
1536
+ /**
1537
+ * Sets endian to little.
1538
+ */
1539
+ little(): void;
1540
+ /**
1541
+ * Sets endian to little.
1542
+ */
1543
+ le(): void;
1544
+ /**
1545
+ * Size in bytes of the current buffer.
1546
+ *
1547
+ * @returns {number} size
1548
+ */
1549
+ get length(): number;
1550
+ /**
1551
+ * Size in bytes of the current buffer.
1552
+ *
1553
+ * @returns {number} size
1554
+ */
1555
+ get len(): number;
1556
+ /**
1557
+ * Size in bytes of the current buffer.
1558
+ *
1559
+ * @returns {number} size
1560
+ */
1561
+ get FileSize(): number;
1562
+ /**
1563
+ * Size in bits of the current buffer.
1564
+ *
1565
+ * @returns {number} size
1566
+ */
1567
+ get lengthB(): number;
1568
+ /**
1569
+ * Size in bits of the current buffer.
1570
+ *
1571
+ * @returns {number} size
1572
+ */
1573
+ get FileSizeB(): number;
1574
+ /**
1575
+ * Size in bits of the current buffer.
1576
+ *
1577
+ * @returns {number} size
1578
+ */
1579
+ get lenb(): number;
1580
+ /**
1581
+ * Get the current byte position.
1582
+ *
1583
+ * @return {number} current byte position
1584
+ */
1585
+ get tell(): number;
1586
+ /**
1587
+ * Get the current byte position.
1588
+ *
1589
+ * @return {number} current byte position
1590
+ */
1591
+ get FTell(): number;
1592
+ /**
1593
+ * Get the current byte position.
1594
+ *
1595
+ * @return {number} current byte position
1596
+ */
1597
+ get getOffset(): number;
1598
+ /**
1599
+ * Get the current byte position;
1600
+ *
1601
+ * @return {number} current byte position
1602
+ */
1603
+ get saveOffset(): number;
1604
+ /**
1605
+ * Get the current byte position;
1606
+ *
1607
+ * @return {number} current byte position
1608
+ */
1609
+ get off(): number;
1610
+ /**
1611
+ * Get the current bit position (0-7).
1612
+ *
1613
+ * @return {number} current bit position
1614
+ */
1615
+ get getOffsetBit(): number;
1616
+ /**
1617
+ * Get the current bit position (0-7).
1618
+ *
1619
+ * @return {number} current bit position
1620
+ */
1621
+ get tellB(): number;
1622
+ /**
1623
+ * Get the current bit position (0-7).
1624
+ *
1625
+ * @return {number} current bit position
1626
+ */
1627
+ get FTellB(): number;
1628
+ /**
1629
+ * Get the current bit position (0-7).
1630
+ *
1631
+ * @return {number} current bit position
1632
+ */
1633
+ get offb(): number;
1634
+ /**
1635
+ * Get the current absolute bit position (from start of data).
1636
+ *
1637
+ * @return {number} current absolute bit position
1638
+ */
1639
+ get getOffsetAbsBit(): number;
1640
+ /**
1641
+ * Get the current absolute bit position (from start of data).
1642
+ *
1643
+ * @return {number} current bit position
1644
+ */
1645
+ get saveOffsetAbsBit(): number;
1646
+ /**
1647
+ * Get the current absolute bit position (from start of data).
1648
+ *
1649
+ * @return {number} current absolute bit position
1650
+ */
1651
+ get tellAbsB(): number;
1652
+ /**
1653
+ * Get the current absolute bit position (from start of data).
1654
+ *
1655
+ * @return {number} current absolute bit position
1656
+ */
1657
+ get saveOffsetBit(): number;
1658
+ /**
1659
+ * Get the current absolute bit position (from start of data).
1660
+ *
1661
+ * @return {number} current absolute bit position
1662
+ */
1663
+ get offab(): number;
1664
+ /**
1665
+ * Size in bytes of current read position to the end
1666
+ *
1667
+ * @returns {number} size
1668
+ */
1669
+ get remain(): number;
1670
+ /**
1671
+ * Size in bytes of current read position to the end
1672
+ *
1673
+ * @returns {number} size
1674
+ */
1675
+ get FEoF(): number;
1676
+ /**
1677
+ * Size in bits of current read position to the end
1678
+ *
1679
+ * @returns {number} size
1680
+ */
1681
+ get remainB(): number;
1682
+ /**
1683
+ * Size in bits of current read position to the end
1684
+ *
1685
+ * @returns {number} size
1686
+ */
1687
+ get FEoFB(): number;
1688
+ /**
1689
+ * Row line of the file (16 bytes per row).
1690
+ *
1691
+ * @returns {number} size
1692
+ */
1693
+ get getLine(): number;
1694
+ /**
1695
+ * Row line of the file (16 bytes per row).
1696
+ *
1697
+ * @returns {number} size
1698
+ */
1699
+ get row(): number;
1700
+ /**
1701
+ * Returns current data.
1702
+ *
1703
+ * Note: Will remove all data after current position if ``extendBufferSize`` was set.
1704
+ *
1705
+ * Use ``.data`` instead if you want the full buffer data.
1706
+ *
1707
+ * @returns {Buffer|Uint8Array} ``Buffer``
1708
+ */
1709
+ get get(): Buffer;
1710
+ /**
1711
+ * Returns current data.
1712
+ *
1713
+ * Note: Will remove all data after current position if ``extendBufferSize`` was set.
1714
+ *
1715
+ * Use ``.data`` instead if you want the full buffer data.
1716
+ *
1717
+ * @returns {Buffer} ``Buffer``
1718
+ */
1719
+ get return(): Buffer;
1720
+ /**
1721
+ * Creates hex dump string. Will console log or return string if set in options.
1722
+ *
1723
+ * @param {object} options
1724
+ * @param {hexdumpOptions?} options - hex dump options
1725
+ * @param {number?} options.length - number of bytes to log, default ``192`` or end of data
1726
+ * @param {number?} options.startByte - byte to start dump (default ``0``)
1727
+ * @param {boolean?} options.supressUnicode - Supress unicode character preview for even columns.
1728
+ * @param {boolean?} options.returnString - Returns the hex dump string instead of logging it.
1729
+ */
1730
+ hexdump(options?: hexdumpOptions): void | string;
1731
+ /**
1732
+ * Turn hexdump on error off (default on).
1733
+ */
1734
+ errorDumpOff(): void;
1735
+ /**
1736
+ * Turn hexdump on error on (default on).
1737
+ */
1738
+ errorDumpOn(): void;
1739
+ /**
1740
+ * Disallows extending data if position is outside of max size.
1741
+ */
1742
+ restrict(): void;
1743
+ /**
1744
+ * Allows extending data if position is outside of max size.
1745
+ */
1746
+ unrestrict(): void;
1747
+ /**
1748
+ * removes data.
1749
+ */
1750
+ end(): void;
1751
+ /**
1752
+ * removes data.
1753
+ */
1754
+ done(): void;
1755
+ /**
1756
+ * removes data.
1757
+ */
1758
+ finished(): void;
1759
+ /**
1760
+ * Searches for byte position of string from current read position.
1761
+ *
1762
+ * Returns -1 if not found.
1763
+ *
1764
+ * Does not change current read position.
1765
+ *
1766
+ * @param {string} string - String to search for.
1767
+ */
1768
+ findString(string: string): number;
1769
+ /**
1770
+ * Searches for byte value (can be signed or unsigned) position from current read position.
1771
+ *
1772
+ * Returns -1 if not found.
1773
+ *
1774
+ * Does not change current read position.
1775
+ *
1776
+ * @param {number} value - Number to search for.
1777
+ * @param {boolean} unsigned - If the number is unsigned (default true)
1778
+ * @param {endian} endian - endianness of value (default set endian).
1779
+ */
1780
+ findByte(value: number, unsigned?: boolean, endian?: endian): number;
1781
+ /**
1782
+ * Searches for short value (can be signed or unsigned) position from current read position.
1783
+ *
1784
+ * Returns -1 if not found.
1785
+ *
1786
+ * Does not change current read position.
1787
+ *
1788
+ * @param {number} value - Number to search for.
1789
+ * @param {boolean} unsigned - If the number is unsigned (default true)
1790
+ * @param {endian} endian - endianness of value (default set endian).
1791
+ */
1792
+ findShort(value: number, unsigned?: boolean, endian?: endian): number;
1793
+ /**
1794
+ * Searches for integer value (can be signed or unsigned) position from current read position.
1795
+ *
1796
+ * Returns -1 if not found.
1797
+ *
1798
+ * Does not change current read position.
1799
+ *
1800
+ * @param {number} value - Number to search for.
1801
+ * @param {boolean} unsigned - If the number is unsigned (default true)
1802
+ * @param {endian} endian - endianness of value (default set endian).
1803
+ */
1804
+ findInt(value: number, unsigned?: boolean, endian?: endian): number;
1805
+ /**
1806
+ * Searches for 64 bit value (can be signed or unsigned) position from current read position.
1807
+ *
1808
+ * Returns -1 if not found.
1809
+ *
1810
+ * Does not change current read position.
1811
+ *
1812
+ * @param {number} value - Number to search for.
1813
+ * @param {boolean} unsigned - If the number is unsigned (default true)
1814
+ * @param {endian} endian - endianness of value (default set endian).
1815
+ */
1816
+ findInt64(value: number, unsigned?: boolean, endian?: endian): number;
1817
+ /**
1818
+ * Searches for half float value position from current read position.
1819
+ *
1820
+ * Returns -1 if not found.
1821
+ *
1822
+ * Does not change current read position.
1823
+ *
1824
+ * @param {number} value - Number to search for.
1825
+ * @param {endian} endian - endianness of value (default set endian).
1826
+ */
1827
+ findHalfFloat(value: number, endian?: endian): number;
1828
+ /**
1829
+ * Searches for float value position from current read position.
1830
+ *
1831
+ * Returns -1 if not found.
1832
+ *
1833
+ * Does not change current read position.
1834
+ *
1835
+ * @param {number} value - Number to search for.
1836
+ * @param {endian} endian - endianness of value (default set endian).
1837
+ */
1838
+ findFloat(value: number, endian?: endian): number;
1839
+ /**
1840
+ * Searches for double float value position from current read position.
1841
+ *
1842
+ * Returns -1 if not found.
1843
+ *
1844
+ * Does not change current read position.
1845
+ *
1846
+ * @param {number} value - Number to search for.
1847
+ * @param {endian} endian - endianness of value (default set endian).
1848
+ */
1849
+ findDoubleFloat(value: number, endian?: endian): number;
1850
+ /**
1851
+ * Aligns current byte position.
1852
+ *
1853
+ * Note: Will extend array if strict mode is off and outside of max size.
1854
+ *
1855
+ * @param {number} number - Byte to align
1856
+ */
1857
+ align(number: number): void;
1858
+ /**
1859
+ * Reverse aligns current byte position.
1860
+ *
1861
+ * Note: Will extend array if strict mode is off and outside of max size.
1862
+ *
1863
+ * @param {number} number - Byte to align
1864
+ */
1865
+ alignRev(number: number): void;
1866
+ /**
1867
+ * Offset current byte or bit position.
1868
+ *
1869
+ * Note: Will extend array if strict mode is off and outside of max size.
1870
+ *
1871
+ * @param {number} bytes - Bytes to skip
1872
+ * @param {number} bits - Bits to skip
1873
+ */
1874
+ skip(bytes: number, bits?: number): void;
1875
+ /**
1876
+ * Offset current byte or bit position.
1877
+ *
1878
+ * Note: Will extend array if strict mode is off and outside of max size.
1879
+ *
1880
+ * @param {number} bytes - Bytes to skip
1881
+ * @param {number} bits - Bits to skip
1882
+ */
1883
+ jump(bytes: number, bits?: number): void;
1884
+ /**
1885
+ * Change position directly to address.
1886
+ *
1887
+ * Note: Will extend array if strict mode is off and outside of max size.
1888
+ *
1889
+ * @param {number} byte - byte to set to
1890
+ * @param {number} bit - bit to set to
1891
+ */
1892
+ FSeek(byte: number, bit?: number): void;
1893
+ /**
1894
+ * Offset current byte or bit position.
1895
+ *
1896
+ * Note: Will extend array if strict mode is off and outside of max size.
1897
+ *
1898
+ * @param {number} bytes - Bytes to skip
1899
+ * @param {number} bits - Bits to skip
1900
+ */
1901
+ seek(bytes: number, bits?: number): void;
1902
+ /**
1903
+ * Change position directly to address.
1904
+ *
1905
+ * Note: Will extend array if strict mode is off and outside of max size.
1906
+ *
1907
+ * @param {number} byte - byte to set to
1908
+ * @param {number} bit - bit to set to
1909
+ */
1910
+ goto(byte: number, bit?: number): void;
1911
+ /**
1912
+ * Change position directly to address.
1913
+ *
1914
+ * Note: Will extend array if strict mode is off and outside of max size.
1915
+ *
1916
+ * @param {number} byte - byte to set to
1917
+ * @param {number} bit - bit to set to
1918
+ */
1919
+ pointer(byte: number, bit?: number): void;
1920
+ /**
1921
+ * Change position directly to address.
1922
+ *
1923
+ * Note: Will extend array if strict mode is off and outside of max size.
1924
+ *
1925
+ * @param {number} byte - byte to set to
1926
+ * @param {number} bit - bit to set to
1927
+ */
1928
+ warp(byte: number, bit?: number): void;
1929
+ /**
1930
+ * Set byte and bit position to start of data.
1931
+ */
1932
+ rewind(): void;
1933
+ /**
1934
+ * Set byte and bit position to start of data.
1935
+ */
1936
+ gotoStart(): void;
1937
+ /**
1938
+ * Set current byte and bit position to end of data.
1939
+ */
1940
+ last(): void;
1941
+ /**
1942
+ * Set current byte and bit position to end of data.
1943
+ */
1944
+ gotoEnd(): void;
1945
+ /**
1946
+ * Set byte and bit position to start of data.
1947
+ */
1948
+ EoF(): void;
1949
+ /**
1950
+ * Deletes part of data from start to current byte position unless supplied, returns removed.
1951
+ *
1952
+ * Note: Errors in strict mode.
1953
+ *
1954
+ * @param {number} startOffset - Start location (default 0)
1955
+ * @param {number} endOffset - End location (default current position)
1956
+ * @param {boolean} consume - Move position to end of removed data (default false)
1957
+ * @returns {Buffer} Removed data as ``Buffer``
1958
+ */
1959
+ delete(startOffset?: number, endOffset?: number, consume?: boolean): Buffer;
1960
+ /**
1961
+ * Deletes part of data from current byte position to end, returns removed.
1962
+ *
1963
+ * Note: Errors in strict mode.
1964
+ *
1965
+ * @returns {Buffer} Removed data as ``Buffer``
1966
+ */
1967
+ clip(): Buffer;
1968
+ /**
1969
+ * Deletes part of data from current byte position to end, returns removed.
1970
+ *
1971
+ * Note: Errors in strict mode.
1972
+ *
1973
+ * @returns {Buffer} Removed data as ``Buffer``
1974
+ */
1975
+ trim(): Buffer;
1976
+ /**
1977
+ * Deletes part of data from current byte position to supplied length, returns removed.
1978
+ *
1979
+ * Note: Errors in strict mode.
1980
+ *
1981
+ * @param {number} length - Length of data in bytes to remove
1982
+ * @param {boolean} consume - Move position to end of removed data (default false)
1983
+ * @returns {Buffer} Removed data as ``Buffer``
1984
+ */
1985
+ crop(length: number, consume?: boolean): Buffer;
1986
+ /**
1987
+ * Deletes part of data from current position to supplied length, returns removed.
1988
+ *
1989
+ * Note: Only works in strict mode.
1990
+ *
1991
+ * @param {number} length - Length of data in bytes to remove
1992
+ * @param {boolean} consume - Move position to end of removed data (default false)
1993
+ * @returns {Buffer} Removed data as ``Buffer``
1994
+ */
1995
+ drop(length: number, consume?: boolean): Buffer;
1996
+ /**
1997
+ * Replaces data in data.
1998
+ *
1999
+ * Note: Errors on strict mode.
2000
+ *
2001
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
2002
+ * @param {boolean} consume - Move current byte position to end of data (default false)
2003
+ * @param {number} offset - Offset to add it at (defaults to current position)
2004
+ */
2005
+ replace(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
2006
+ /**
2007
+ * Replaces data in data.
2008
+ *
2009
+ * Note: Errors on strict mode.
2010
+ *
2011
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
2012
+ * @param {boolean} consume - Move current byte position to end of data (default false)
2013
+ * @param {number} offset - Offset to add it at (defaults to current position)
2014
+ */
2015
+ overwrite(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
2016
+ /**
2017
+ * Returns part of data from current byte position to end of data unless supplied.
2018
+ *
2019
+ * @param {number} startOffset - Start location (default current position)
2020
+ * @param {number} endOffset - End location (default end of data)
2021
+ * @param {boolean} consume - Move position to end of lifted data (default false)
2022
+ * @param {number} fillValue - Byte value to to fill returned data (does NOT fill unless supplied)
2023
+ * @returns {Buffer} Selected data as ``Buffer``
2024
+ */
2025
+ lift(startOffset?: number, endOffset?: number, consume?: boolean, fillValue?: number): Buffer;
2026
+ /**
2027
+ * Returns part of data from current byte position to end of data unless supplied.
2028
+ *
2029
+ * @param {number} startOffset - Start location (default current position)
2030
+ * @param {number} endOffset - End location (default end of data)
2031
+ * @param {boolean} consume - Move position to end of lifted data (default false)
2032
+ * @param {number} fillValue - Byte value to to fill returned data (does NOT fill unless supplied)
2033
+ * @returns {Buffer} Selected data as ``Buffer``
2034
+ */
2035
+ fill(startOffset?: number, endOffset?: number, consume?: boolean, fillValue?: number): Buffer;
2036
+ /**
2037
+ * Extract data from current position to length supplied.
2038
+ *
2039
+ * Note: Does not affect supplied data.
2040
+ *
2041
+ * @param {number} length - Length of data in bytes to copy from current offset
2042
+ * @param {number} consume - Moves offset to end of length
2043
+ * @returns {Buffer} Selected data as ``Buffer``
2044
+ */
2045
+ extract(length: number, consume?: boolean): Buffer;
2046
+ /**
2047
+ * Extract data from current position to length supplied.
2048
+ *
2049
+ * Note: Does not affect supplied data.
2050
+ *
2051
+ * @param {number} length - Length of data in bytes to copy from current offset
2052
+ * @param {number} consume - Moves offset to end of length
2053
+ * @returns {Buffer} Selected data as ``Buffer``
2054
+ */
2055
+ slice(length: number, consume?: boolean): Buffer;
2056
+ /**
2057
+ * Extract data from current position to length supplied.
2058
+ *
2059
+ * Note: Does not affect supplied data.
2060
+ *
2061
+ * @param {number} length - Length of data in bytes to copy from current offset
2062
+ * @param {number} consume - Moves offset to end of length
2063
+ * @returns {Buffer|Uint8Array} Selected data or ``Buffer``
2064
+ */
2065
+ wrap(length: number, consume?: boolean): Buffer;
2066
+ /**
2067
+ * Inserts data into data.
2068
+ *
2069
+ * Note: Errors on strict mode.
2070
+ *
2071
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
2072
+ * @param {boolean} consume - Move current byte position to end of data (default false)
2073
+ * @param {number} offset - Byte position to add at (defaults to current position)
2074
+ */
2075
+ insert(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
2076
+ /**
2077
+ * Inserts data into data.
2078
+ *
2079
+ * Note: Errors on strict mode.
2080
+ *
2081
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
2082
+ * @param {boolean} consume - Move current byte position to end of data (default false)
2083
+ * @param {number} offset - Byte position to add at (defaults to current position)
2084
+ */
2085
+ place(data: Buffer | Uint8Array, consume?: boolean, offset?: number): void;
2086
+ /**
2087
+ * Adds data to start of supplied data.
2088
+ *
2089
+ * Note: Errors on strict mode.
2090
+ *
2091
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
2092
+ * @param {boolean} consume - Move current write position to end of data (default false)
2093
+ */
2094
+ unshift(data: Buffer | Uint8Array, consume?: boolean): void;
2095
+ /**
2096
+ * Adds data to start of supplied data.
2097
+ *
2098
+ * Note: Errors on strict mode.
2099
+ *
2100
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
2101
+ * @param {boolean} consume - Move current write position to end of data (default false)
2102
+ */
2103
+ prepend(data: Buffer | Uint8Array, consume?: boolean): void;
2104
+ /**
2105
+ * Adds data to end of supplied data.
2106
+ *
2107
+ * Note: Errors on strict mode.
2108
+ *
2109
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
2110
+ * @param {boolean} consume - Move current write position to end of data (default false)
2111
+ */
2112
+ push(data: Buffer | Uint8Array, consume?: boolean): void;
2113
+ /**
2114
+ * Adds data to end of supplied data.
2115
+ *
2116
+ * Note: Errors on strict mode.
2117
+ *
2118
+ * @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
2119
+ * @param {boolean} consume - Move current write position to end of data (default false)
2120
+ */
2121
+ append(data: Buffer | Uint8Array, consume?: boolean): void;
2122
+ /**
2123
+ * XOR data.
2124
+ *
2125
+ * @param {number|string|Uint8Array|Buffer} xorKey - Value, string or array to XOR
2126
+ * @param {number} startOffset - Start location (default current byte position)
2127
+ * @param {number} endOffset - End location (default end of data)
2128
+ * @param {boolean} consume - Move current position to end of data (default false)
2129
+ */
2130
+ xor(xorKey: number | string | Uint8Array | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
2131
+ /**
2132
+ * XOR data.
2133
+ *
2134
+ * @param {number|string|Uint8Array|Buffer} xorKey - Value, string or array to XOR
2135
+ * @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)
2136
+ * @param {boolean} consume - Move current position to end of data (default false)
2137
+ */
2138
+ xorThis(xorKey: number | string | Uint8Array | Buffer, length?: number, consume?: boolean): void;
2139
+ /**
2140
+ * OR data
2141
+ *
2142
+ * @param {number|string|Uint8Array|Buffer} orKey - Value, string or array to OR
2143
+ * @param {number} startOffset - Start location (default current byte position)
2144
+ * @param {number} endOffset - End location (default end of data)
2145
+ * @param {boolean} consume - Move current position to end of data (default false)
2146
+ */
2147
+ or(orKey: number | string | Uint8Array | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
2148
+ /**
2149
+ * OR data.
2150
+ *
2151
+ * @param {number|string|Uint8Array|Buffer} orKey - Value, string or array to OR
2152
+ * @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)
2153
+ * @param {boolean} consume - Move current position to end of data (default false)
2154
+ */
2155
+ orThis(orKey: number | string | Uint8Array | Buffer, length?: number, consume?: boolean): void;
2156
+ /**
2157
+ * AND data.
2158
+ *
2159
+ * @param {number|string|Array<number>|Buffer} andKey - Value, string or array to AND
2160
+ * @param {number} startOffset - Start location (default current byte position)
2161
+ * @param {number} endOffset - End location (default end of data)
2162
+ * @param {boolean} consume - Move current position to end of data (default false)
2163
+ */
2164
+ and(andKey: number | string | Array<number> | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
2165
+ /**
2166
+ * AND data.
2167
+ *
2168
+ * @param {number|string|Array<number>|Buffer} andKey - Value, string or array to AND
2169
+ * @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)
2170
+ * @param {boolean} consume - Move current position to end of data (default false)
2171
+ */
2172
+ andThis(andKey: number | string | Array<number> | Buffer, length?: number, consume?: boolean): void;
2173
+ /**
2174
+ * Add value to data.
2175
+ *
2176
+ * @param {number|string|Array<number>|Buffer} addKey - Value, string or array to add to data
2177
+ * @param {number} startOffset - Start location (default current byte position)
2178
+ * @param {number} endOffset - End location (default end of data)
2179
+ * @param {boolean} consume - Move current position to end of data (default false)
2180
+ */
2181
+ add(addKey: number | string | Array<number> | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
2182
+ /**
2183
+ * Add value to data.
2184
+ *
2185
+ * @param {number|string|Array<number>|Buffer} addKey - Value, string or array to add to data
2186
+ * @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)
2187
+ * @param {boolean} consume - Move current position to end of data (default false)
2188
+ */
2189
+ addThis(addKey: number | string | Array<number> | Buffer, length?: number, consume?: boolean): void;
2190
+ /**
2191
+ * Not data.
2192
+ *
2193
+ * @param {number} startOffset - Start location (default current byte position)
2194
+ * @param {number} endOffset - End location (default end of data)
2195
+ * @param {boolean} consume - Move current position to end of data (default false)
2196
+ */
2197
+ not(startOffset?: number, endOffset?: number, consume?: boolean): void;
2198
+ /**
2199
+ * Not data.
2200
+ *
2201
+ * @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)
2202
+ * @param {boolean} consume - Move current position to end of data (default false)
2203
+ */
2204
+ notThis(length?: number, consume?: boolean): void;
2205
+ /**
2206
+ * Left shift data.
2207
+ *
2208
+ * @param {number|string|Array<number>|Buffer} shiftKey - Value, string or array to left shift data
2209
+ * @param {number} startOffset - Start location (default current byte position)
2210
+ * @param {number} endOffset - End location (default end of data)
2211
+ * @param {boolean} consume - Move current position to end of data (default false)
2212
+ */
2213
+ lShift(shiftKey: number | string | Array<number> | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
2214
+ /**
2215
+ * Left shift data.
2216
+ *
2217
+ * @param {number|string|Array<number>|Buffer} shiftKey - Value, string or array to left shift data
2218
+ * @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)
2219
+ * @param {boolean} consume - Move current position to end of data (default false)
2220
+ */
2221
+ lShiftThis(shiftKey: number | string | Array<number> | Buffer, length?: number, consume?: boolean): void;
2222
+ /**
2223
+ * Right shift data.
2224
+ *
2225
+ * @param {number|string|Array<number>|Buffer} shiftKey - Value, string or array to right shift data
2226
+ * @param {number} startOffset - Start location (default current byte position)
2227
+ * @param {number} endOffset - End location (default end of data)
2228
+ * @param {boolean} consume - Move current position to end of data (default false)
2229
+ */
2230
+ rShift(shiftKey: number | string | Array<number> | Buffer, startOffset?: number, endOffset?: number, consume?: boolean): void;
2231
+ /**
2232
+ * Right shift data.
2233
+ *
2234
+ * @param {number|string|Array<number>|Buffer} shiftKey - Value, string or array to right shift data
2235
+ * @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)
2236
+ * @param {boolean} consume - Move current position to end of data (default false)
2237
+ */
2238
+ rShiftThis(shiftKey: number | string | Array<number> | Buffer, length?: number, consume?: boolean): void;
2239
+ /**
2240
+ *
2241
+ * Write bits, must have at least value and number of bits.
2242
+ *
2243
+ * ``Note``: When returning to a byte write, remaining bits are skipped.
2244
+ *
2245
+ * @param {number} value - value as int
2246
+ * @param {number} bits - number of bits to write
2247
+ * @param {boolean} unsigned - if value is unsigned
2248
+ * @param {endian} endian - ``big`` or ``little``
2249
+ */
2250
+ writeBit(value: number, bits: number, unsigned?: boolean, endian?: endian): void;
2251
+ /**
2252
+ * Bit field writer.
2253
+ *
2254
+ * Note: When returning to a byte write, remaining bits are dropped.
2255
+ *
2256
+ * @param {number} value - value as int
2257
+ * @param {number} bits - bits to write
2258
+ * @returns number
2259
+ */
2260
+ writeUBitBE(value: number, bits: number): void;
2261
+ /**
2262
+ * Bit field writer.
2263
+ *
2264
+ * Note: When returning to a byte write, remaining bits are dropped.
2265
+ *
2266
+ * @param {number} value - value as int
2267
+ * @param {number} bits - bits to write
2268
+ * @param {boolean} unsigned - if the value is unsigned
2269
+ * @returns number
2270
+ */
2271
+ writeBitBE(value: number, bits: number, unsigned?: boolean): void;
2272
+ /**
2273
+ * Bit field writer.
2274
+ *
2275
+ * Note: When returning to a byte write, remaining bits are dropped.
2276
+ *
2277
+ * @param {number} value - value as int
2278
+ * @param {number} bits - bits to write
2279
+ * @returns number
2280
+ */
2281
+ writeUBitLE(value: number, bits: number): void;
2282
+ /**
2283
+ * Bit field writer.
2284
+ *
2285
+ * Note: When returning to a byte write, remaining bits are dropped.
2286
+ *
2287
+ * @param {number} value - value as int
2288
+ * @param {number} bits - bits to write
2289
+ * @param {boolean} unsigned - if the value is unsigned
2290
+ * @returns number
2291
+ */
2292
+ writeBitLE(value: number, bits: number, unsigned?: boolean): void;
2293
+ /**
2294
+ * Bit field reader.
2295
+ *
2296
+ * Note: When returning to a byte read, remaining bits are dropped.
2297
+ *
2298
+ * @param {number} bits - bits to read
2299
+ * @param {boolean} unsigned - if the value is unsigned
2300
+ * @param {endian} endian - ``big`` or ``little``
2301
+ * @returns {number}
2302
+ */
2303
+ readBit(bits?: number, unsigned?: boolean, endian?: endian): number;
2304
+ /**
2305
+ * Bit field reader.
2306
+ *
2307
+ * Note: When returning to a byte read, remaining bits are dropped.
2308
+ *
2309
+ * @param {number} bits - bits to read
2310
+ * @returns {number}
2311
+ */
2312
+ readUBitBE(bits: number): number;
2313
+ /**
2314
+ * Bit field reader.
2315
+ *
2316
+ * Note: When returning to a byte read, remaining bits are dropped.
2317
+ *
2318
+ * @param {number} bits - bits to read
2319
+ * @param {boolean} unsigned - if the value is unsigned
2320
+ * @returns {number}
2321
+ */
2322
+ readBitBE(bits: number, unsigned?: boolean): number;
2323
+ /**
2324
+ * Bit field reader.
2325
+ *
2326
+ * Note: When returning to a byte read, remaining bits are dropped.
2327
+ *
2328
+ * @param {number} bits - bits to read
2329
+ * @returns {number}
2330
+ */
2331
+ readUBitLE(bits: number): number;
2332
+ /**
2333
+ * Bit field reader.
2334
+ *
2335
+ * Note: When returning to a byte read, remaining bits are dropped.
2336
+ *
2337
+ * @param {number} bits - bits to read
2338
+ * @param {boolean} unsigned - if the value is unsigned
2339
+ * @returns {number}
2340
+ */
2341
+ readBitLE(bits: number, unsigned?: boolean): number;
2342
+ /**
2343
+ * Read byte.
2344
+ *
2345
+ * @param {boolean} unsigned - if value is unsigned or not
2346
+ * @returns {number}
2347
+ */
2348
+ readByte(unsigned?: boolean): number;
2349
+ /**
2350
+ * Read multiple bytes.
2351
+ *
2352
+ * @param {number} amount - amount of bytes to read
2353
+ * @param {boolean} unsigned - if value is unsigned or not
2354
+ * @returns {number[]}
2355
+ */
2356
+ readBytes(amount: number, unsigned?: boolean): number[];
2357
+ /**
2358
+ * Write byte.
2359
+ *
2360
+ * @param {number} value - value as int
2361
+ * @param {boolean} unsigned - if the value is unsigned
2362
+ */
2363
+ writeByte(value: number, unsigned?: boolean): void;
2364
+ /**
2365
+ * Write multiple bytes.
2366
+ *
2367
+ * @param {number[]} values - array of values as int
2368
+ * @param {boolean} unsigned - if the value is unsigned
2369
+ */
2370
+ writeBytes(values: number[], unsigned?: boolean): void;
2371
+ /**
2372
+ * Write unsigned byte.
2373
+ *
2374
+ * @param {number} value - value as int
2375
+ */
2376
+ writeUByte(value: number): void;
2377
+ /**
2378
+ * Read unsigned byte.
2379
+ *
2380
+ * @returns {number}
2381
+ */
2382
+ readUByte(): number;
2383
+ /**
2384
+ * Read short.
2385
+ *
2386
+ * @param {boolean} unsigned - if value is unsigned or not
2387
+ * @param {endian} endian - ``big`` or ``little``
2388
+ * @returns {number}
2389
+ */
2390
+ readInt16(unsigned?: boolean, endian?: endian): number;
2391
+ /**
2392
+ * Write int16.
2393
+ *
2394
+ * @param {number} value - value as int
2395
+ * @param {boolean} unsigned - if the value is unsigned
2396
+ * @param {endian} endian - ``big`` or ``little``
2397
+ */
2398
+ writeInt16(value: number, unsigned?: boolean, endian?: endian): void;
2399
+ /**
2400
+ * Write unsigned int16.
2401
+ *
2402
+ * @param {number} value - value as int
2403
+ * @param {endian} endian - ``big`` or ``little``
2404
+ */
2405
+ writeUInt16(value: number, endian?: endian): void;
2406
+ /**
2407
+ * Write unsigned int16.
2408
+ *
2409
+ * @param {number} value - value as int
2410
+ */
2411
+ writeUInt16BE(value: number): void;
2412
+ /**
2413
+ * Write unsigned int16.
2414
+ *
2415
+ * @param {number} value - value as int
2416
+ */
2417
+ writeUInt16LE(value: number): void;
2418
+ /**
2419
+ * Write signed int16.
2420
+ *
2421
+ * @param {number} value - value as int
2422
+ */
2423
+ writeInt16LE(value: number): void;
2424
+ /**
2425
+ * Read unsigned short.
2426
+ *
2427
+ * @param {endian} endian - ``big`` or ``little``
2428
+ *
2429
+ * @returns {number}
2430
+ */
2431
+ readUInt16(endian?: endian): number;
2432
+ /**
2433
+ * Read unsigned short in little endian.
2434
+ *
2435
+ * @returns {number}
2436
+ */
2437
+ readUInt16LE(): number;
2438
+ /**
2439
+ * Read signed short in little endian.
2440
+ *
2441
+ * @returns {number}
2442
+ */
2443
+ readInt16LE(): number;
2444
+ /**
2445
+ * Read unsigned short in big endian.
2446
+ *
2447
+ * @returns {number}
2448
+ */
2449
+ readUInt16BE(): number;
2450
+ /**
2451
+ * Read signed short in big endian.
2452
+ *
2453
+ * @returns {number}
2454
+ */
2455
+ readInt16BE(): number;
2456
+ /**
2457
+ * Read half float.
2458
+ *
2459
+ * @param {endian} endian - ``big`` or ``little``
2460
+ * @returns {number}
2461
+ */
2462
+ readHalfFloat(endian?: endian): number;
2463
+ /**
2464
+ * Writes half float.
2465
+ *
2466
+ * @param {number} value - value as int
2467
+ * @param {endian} endian - ``big`` or ``little``
2468
+ */
2469
+ writeHalfFloat(value: number, endian?: endian): void;
2470
+ /**
2471
+ * Writes half float.
2472
+ *
2473
+ * @param {number} value - value as int
2474
+ */
2475
+ writeHalfFloatBE(value: number): void;
2476
+ /**
2477
+ * Writes half float.
2478
+ *
2479
+ * @param {number} value - value as int
2480
+ */
2481
+ writeHalfFloatLE(value: number): void;
2482
+ /**
2483
+ * Read half float.
2484
+ *
2485
+ * @returns {number}
2486
+ */
2487
+ readHalfFloatBE(): number;
2488
+ /**
2489
+ * Read half float.
2490
+ *
2491
+ * @returns {number}
2492
+ */
2493
+ readHalfFloatLE(): number;
2494
+ /**
2495
+ * Read 32 bit integer.
2496
+ *
2497
+ * @param {boolean} unsigned - if value is unsigned or not
2498
+ * @param {endian} endian - ``big`` or ``little``
2499
+ * @returns {number}
2500
+ */
2501
+ readInt32(unsigned?: boolean, endian?: endian): number;
2502
+ /**
2503
+ * Write int32.
2504
+ *
2505
+ * @param {number} value - value as int
2506
+ * @param {boolean} unsigned - if the value is unsigned
2507
+ * @param {endian} endian - ``big`` or ``little``
2508
+ */
2509
+ writeInt32(value: number, unsigned?: boolean, endian?: endian): void;
2510
+ /**
2511
+ * Write unsigned int32.
2512
+ *
2513
+ * @param {number} value - value as int
2514
+ * @param {endian} endian - ``big`` or ``little``
2515
+ */
2516
+ writeUInt32(value: number, endian?: endian): void;
2517
+ /**
2518
+ * Write signed int32.
2519
+ *
2520
+ * @param {number} value - value as int
2521
+ */
2522
+ writeInt32LE(value: number): void;
2523
+ /**
2524
+ * Write unsigned int32.
2525
+ *
2526
+ * @param {number} value - value as int
2527
+ */
2528
+ writeUInt32LE(value: number): void;
2529
+ /**
2530
+ * Write signed int32.
2531
+ *
2532
+ * @param {number} value - value as int
2533
+ */
2534
+ writeInt32BE(value: number): void;
2535
+ /**
2536
+ * Read signed 32 bit integer.
2537
+ *
2538
+ * @returns {number}
2539
+ */
2540
+ readInt32BE(): number;
2541
+ /**
2542
+ * Read unsigned 32 bit integer.
2543
+ *
2544
+ * @returns {number}
2545
+ */
2546
+ readUInt32BE(): number;
2547
+ /**
2548
+ * Read signed 32 bit integer.
2549
+ *
2550
+ * @returns {number}
2551
+ */
2552
+ readInt32LE(): number;
2553
+ /**
2554
+ * Read signed 32 bit integer.
2555
+ *
2556
+ * @returns {number}
2557
+ */
2558
+ readUInt32LE(): number;
2559
+ /**
2560
+ * Read unsigned 32 bit integer.
2561
+ *
2562
+ * @returns {number}
2563
+ */
2564
+ readUInt(): number;
2565
+ /**
2566
+ * Read float.
2567
+ *
2568
+ * @param {endian} endian - ``big`` or ``little``
2569
+ * @returns {number}
2570
+ */
2571
+ readFloat(endian?: endian): number;
2572
+ /**
2573
+ * Write float.
2574
+ *
2575
+ * @param {number} value - value as int
2576
+ * @param {endian} endian - ``big`` or ``little``
2577
+ */
2578
+ writeFloat(value: number, endian?: endian): void;
2579
+ /**
2580
+ * Write float.
2581
+ *
2582
+ * @param {number} value - value as int
2583
+ */
2584
+ writeFloatLE(value: number): void;
2585
+ /**
2586
+ * Write float.
2587
+ *
2588
+ * @param {number} value - value as int
2589
+ */
2590
+ writeFloatBE(value: number): void;
2591
+ /**
2592
+ * Read float.
2593
+ *
2594
+ * @returns {number}
2595
+ */
2596
+ readFloatBE(): number;
2597
+ /**
2598
+ * Read float.
2599
+ *
2600
+ * @returns {number}
2601
+ */
2602
+ readFloatLE(): number;
2603
+ /**
2604
+ * Read signed 64 bit integer.
2605
+ *
2606
+ * @param {boolean} unsigned - if value is unsigned or not
2607
+ * @param {endian?} endian - ``big`` or ``little``
2608
+ * @returns {number}
2609
+ */
2610
+ readInt64(unsigned?: boolean, endian?: endian): bigint;
2611
+ /**
2612
+ * Write 64 bit integer.
2613
+ *
2614
+ * @param {number} value - value as int
2615
+ * @param {boolean} unsigned - if the value is unsigned
2616
+ * @param {endian} endian - ``big`` or ``little``
2617
+ */
2618
+ writeInt64(value: number, unsigned?: boolean, endian?: endian): void;
2619
+ /**
2620
+ * Write unsigned 64 bit integer.
2621
+ *
2622
+ * @param {number} value - value as int
2623
+ * @param {endian} endian - ``big`` or ``little``
2624
+ */
2625
+ writeUInt64(value: number, endian?: endian): void;
2626
+ /**
2627
+ * Write signed 64 bit integer.
2628
+ *
2629
+ * @param {number} value - value as int
2630
+ */
2631
+ writeInt64LE(value: number): void;
2632
+ /**
2633
+ * Write unsigned 64 bit integer.
2634
+ *
2635
+ * @param {number} value - value as int
2636
+ */
2637
+ writeUInt64LE(value: number): void;
2638
+ /**
2639
+ * Write signed 64 bit integer.
2640
+ *
2641
+ * @param {number} value - value as int
2642
+ */
2643
+ writeInt64BE(value: number): void;
2644
+ /**
2645
+ * Write unsigned 64 bit integer.
2646
+ *
2647
+ * @param {number} value - value as int
2648
+ */
2649
+ writeUInt64BE(value: number): void;
2650
+ /**
2651
+ * Read unsigned 64 bit integer.
2652
+ *
2653
+ * @returns {number}
2654
+ */
2655
+ readUInt64(): bigint;
2656
+ /**
2657
+ * Read signed 64 bit integer.
2658
+ *
2659
+ * @returns {number}
2660
+ */
2661
+ readInt64BE(): bigint;
2662
+ /**
2663
+ * Read unsigned 64 bit integer.
2664
+ *
2665
+ * @returns {number}
2666
+ */
2667
+ readUInt64BE(): bigint;
2668
+ /**
2669
+ * Read signed 64 bit integer.
2670
+ *
2671
+ * @returns {number}
2672
+ */
2673
+ readInt64LE(): bigint;
2674
+ /**
2675
+ * Read unsigned 64 bit integer.
2676
+ *
2677
+ * @returns {number}
2678
+ */
2679
+ readUInt64LE(): bigint;
2680
+ /**
2681
+ * Read double float.
2682
+ *
2683
+ * @param {endian} endian - ``big`` or ``little``
2684
+ * @returns {number}
2685
+ */
2686
+ readDoubleFloat(endian?: endian): number;
2687
+ /**
2688
+ * Writes double float.
2689
+ *
2690
+ * @param {number} value - value as int
2691
+ * @param {endian} endian - ``big`` or ``little``
2692
+ */
2693
+ writeDoubleFloat(value: number, endian?: endian): void;
2694
+ /**
2695
+ * Writes double float.
2696
+ *
2697
+ * @param {number} value - value as int
2698
+ */
2699
+ writeDoubleFloatBE(value: number): void;
2700
+ /**
2701
+ * Writes double float.
2702
+ *
2703
+ * @param {number} value - value as int
2704
+ */
2705
+ writeDoubleFloatLE(value: number): void;
2706
+ /**
2707
+ * Read double float.
2708
+ *
2709
+ * @returns {number}
2710
+ */
2711
+ readDoubleFloatBE(): number;
2712
+ /**
2713
+ * Read double float.
2714
+ *
2715
+ * @returns {number}
2716
+ */
2717
+ readDoubleFloatLE(): number;
2718
+ /**
2719
+ * Reads string, use options object for different types.
2720
+ *
2721
+ * @param {stringOptions} options
2722
+ * @param {stringOptions["length"]?} options.length - for fixed length, non-terminate value utf strings
2723
+ * @param {stringOptions["stringType"]?} options.stringType - utf-8, utf-16, pascal or wide-pascal
2724
+ * @param {stringOptions["terminateValue"]?} options.terminateValue - only with stringType: "utf"
2725
+ * @param {stringOptions["lengthReadSize"]?} options.lengthReadSize - for pascal strings. 1, 2 or 4 byte length read size
2726
+ * @param {stringOptions["encoding"]?} options.encoding - TextEncoder accepted types
2727
+ * @param {stringOptions["endian"]?} options.endian - for wide-pascal and utf-16
2728
+ * @return {Promise<string>}
2729
+ */
2730
+ readString(options?: stringOptions): string;
2731
+ /**
2732
+ * Writes string, use options object for different types.
2733
+ *
2734
+ * @param {string} string - text string
2735
+ * @param {stringOptions?} options
2736
+ * @param {stringOptions["length"]?} options.length - for fixed length, non-terminate value utf strings
2737
+ * @param {stringOptions["stringType"]?} options.stringType - utf-8, utf-16, pascal or wide-pascal
2738
+ * @param {stringOptions["terminateValue"]?} options.terminateValue - only with stringType: "utf"
2739
+ * @param {stringOptions["lengthWriteSize"]?} options.lengthWriteSize - for pascal strings. 1, 2 or 4 byte length write size
2740
+ * @param {stringOptions["encoding"]?} options.encoding - TextEncoder accepted types
2741
+ * @param {stringOptions["endian"]?} options.endian - for wide-pascal and utf-16
2742
+ */
2743
+ writeString(string: string, options?: stringOptions): void;
2744
+ }
2745
+
2746
+ interface BinaryAliasReader extends BiBase {
2747
+ }
2748
+ interface BinaryAliasReaderStreamer extends BiBaseStreamer {
2749
+ }
2750
+
2751
+ declare const BiReaderBase: typeof BiBase;
2752
+ /**
2753
+ * Binary reader, includes bitfields and strings.
2754
+ *
2755
+ * @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
2756
+ * @param {BiOptions?} options - Any options to set at start
2757
+ * @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
2758
+ * @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
2759
+ * @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
2760
+ * @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
2761
+ * @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
2762
+ *
2763
+ * @since 2.0
2764
+ */
2765
+ declare class BiReader extends BiReaderBase implements BinaryAliasReader {
2766
+ /**
2767
+ * Binary reader, includes bitfields and strings.
2768
+ *
2769
+ * @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
2770
+ * @param {BiOptions?} options - Any options to set at start
2771
+ * @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
2772
+ * @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
2773
+ * @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
2774
+ * @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
2775
+ * @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
2776
+ */
2777
+ constructor(data: Buffer | Uint8Array, options?: BiOptions);
2778
+ }
2779
+
2780
+ interface BinaryAliasWriter extends BiBase {
2781
+ }
2782
+ interface BinaryAliasWriterStreamer extends BiBaseStreamer {
2783
+ }
2784
+
2785
+ declare const BiWriterBase: typeof BiBase;
2786
+ /**
2787
+ * Binary writer, includes bitfields and strings.
2788
+ *
2789
+ * @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
2790
+ * @param {BiOptions?} options - Any options to set at start
2791
+ * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
2792
+ * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
2793
+ * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
2794
+ * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
2795
+ * @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
2796
+ *
2797
+ * @since 2.0
2798
+ */
2799
+ declare class BiWriter extends BiWriterBase implements BinaryAliasWriter {
2800
+ /**
2801
+ * Binary writer, includes bitfields and strings.
2802
+ *
2803
+ * @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
2804
+ * @param {BiOptions?} options - Any options to set at start
2805
+ * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
2806
+ * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
2807
+ * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
2808
+ * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
2809
+ * @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
2810
+ */
2811
+ constructor(data?: Buffer | Uint8Array, options?: BiOptions);
2812
+ }
2813
+
2814
+ declare const BiReaderStreamer: typeof BiBaseStreamer;
2815
+ /**
2816
+ * Binary reader, includes bitfields and strings.
2817
+ *
2818
+ * @param {string} filePath - Path to file
2819
+ * @param {BiOptions?} options - Any options to set at start
2820
+ * @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
2821
+ * @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
2822
+ * @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
2823
+ * @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
2824
+ * @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
2825
+ *
2826
+ * @since 3.1
2827
+ */
2828
+ declare class BiReaderStream extends BiReaderStreamer implements BinaryAliasReaderStreamer {
2829
+ /**
2830
+ * Binary reader, includes bitfields and strings.
2831
+ *
2832
+ * Note: Must start with .open() before reading.
2833
+ *
2834
+ * @param {string} filePath - Path to file
2835
+ * @param {BiOptions?} options - Any options to set at start
2836
+ * @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
2837
+ * @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
2838
+ * @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
2839
+ * @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
2840
+ * @param {number?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
2841
+ */
2842
+ constructor(filePath: string, options?: BiOptions);
2843
+ }
2844
+
2845
+ declare const BiWriterStreamer: typeof BiBaseStreamer;
2846
+ /**
2847
+ * Binary writer, includes bitfields and strings.
2848
+ *
2849
+ * Note: Must start with .open() before writing.
2850
+ *
2851
+ * @param {string} filePath - Path to file
2852
+ * @param {BiOptions?} options - Any options to set at start
2853
+ * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
2854
+ * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
2855
+ * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
2856
+ * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
2857
+ * @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
2858
+ *
2859
+ * @since 3.1
2860
+ */
2861
+ declare class BiWriterStream extends BiWriterStreamer implements BinaryAliasWriterStreamer {
2862
+ /**
2863
+ * Binary writer, includes bitfields and strings.
2864
+ *
2865
+ * Note: Must start with .open() before writing.
2866
+ *
2867
+ * @param {string} filePath - Path to file
2868
+ * @param {BiOptions?} options - Any options to set at start
2869
+ * @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
2870
+ * @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
2871
+ * @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
2872
+ * @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
2873
+ * @param {BiOptions["extendBufferSize"]?} options.extendBufferSize - Amount of data to add when extending the buffer array when strict mode is false. Note: Changes logic in ``.get`` and ``.return``.
2874
+ */
2875
+ constructor(filePath: string, options?: BiOptions);
2876
+ }
2877
+
2878
+ /**
2879
+ * Not in use anymore.
2880
+ * @since 3.0
2881
+ * @deprecated Use ``BiReader`` instead.
2882
+ */
2883
+ declare class bireader {
2884
+ constructor();
2885
+ }
2886
+ /**
2887
+ * Not in use anymore.
2888
+ * @since 3.0
2889
+ * @deprecated Use ``BiWriter`` instead.
2890
+ */
2891
+ declare class biwriter {
2892
+ constructor();
2893
+ }
2894
+
2895
+ export { BiReader, BiReaderStream, BiWriter, BiWriterStream, bireader, biwriter, hexdump };