bireader 3.0.0 → 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.
- package/README.md +91 -29
- package/dist/BiReader.d.ts +33 -0
- package/dist/BiReaderStream.d.ts +34 -0
- package/dist/BiWriter.d.ts +33 -0
- package/dist/BiWriterStream.d.ts +36 -0
- package/dist/aliases/BinaryAliasReader.d.ts +7 -0
- package/dist/aliases/BinaryAliasWriter.d.ts +7 -0
- package/dist/common.d.ts +90 -0
- package/{build/cjs/common.d.ts → dist/core/BiBase.d.ts} +132 -221
- package/dist/core/BiBaseStream.d.ts +1363 -0
- package/{build/esm/common.d.ts → dist/index.browser.d.ts} +208 -169
- package/dist/index.browser.js +9706 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs.d.ts +2895 -0
- package/dist/index.cjs.js +13662 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +2895 -0
- package/dist/index.esm.d.ts +2895 -0
- package/dist/index.esm.js +13635 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/indexBrowser.d.ts +19 -0
- package/dist/indexImport.d.ts +21 -0
- package/package.json +23 -14
- package/rollup.config.js +76 -0
- package/tsconfig.json +15 -0
- package/build/cjs/bireader.d.ts +0 -2372
- package/build/cjs/bireader.d.ts.map +0 -1
- package/build/cjs/bireader.js +0 -3060
- package/build/cjs/bireader.js.map +0 -1
- package/build/cjs/biwriter.d.ts +0 -2359
- package/build/cjs/biwriter.d.ts.map +0 -1
- package/build/cjs/biwriter.js +0 -3094
- package/build/cjs/biwriter.js.map +0 -1
- package/build/cjs/common.d.ts.map +0 -1
- package/build/cjs/common.js +0 -3615
- package/build/cjs/common.js.map +0 -1
- package/build/cjs/index.d.ts +0 -18
- package/build/cjs/index.d.ts.map +0 -1
- package/build/cjs/index.js +0 -30
- package/build/cjs/index.js.map +0 -1
- package/build/esm/bireader.d.ts +0 -2372
- package/build/esm/bireader.d.ts.map +0 -1
- package/build/esm/bireader.js +0 -3060
- package/build/esm/bireader.js.map +0 -1
- package/build/esm/biwriter.d.ts +0 -2359
- package/build/esm/biwriter.d.ts.map +0 -1
- package/build/esm/biwriter.js +0 -3094
- package/build/esm/biwriter.js.map +0 -1
- package/build/esm/common.d.ts.map +0 -1
- package/build/esm/common.js +0 -3615
- package/build/esm/common.js.map +0 -1
- package/build/esm/index.d.ts +0 -18
- package/build/esm/index.d.ts.map +0 -1
- package/build/esm/index.js +0 -30
- package/build/esm/index.js.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
type
|
|
3
|
-
type
|
|
4
|
-
export type BiOptions = {
|
|
2
|
+
type endian = "little" | "big";
|
|
3
|
+
type BiOptions = {
|
|
5
4
|
/**
|
|
6
5
|
* Byte offset to start writer, default is 0
|
|
7
6
|
*/
|
|
@@ -13,7 +12,7 @@ export type BiOptions = {
|
|
|
13
12
|
/**
|
|
14
13
|
* Endianness ``big`` or ``little`` (default little)
|
|
15
14
|
*/
|
|
16
|
-
endianness?:
|
|
15
|
+
endianness?: endian;
|
|
17
16
|
/**
|
|
18
17
|
* Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
19
18
|
*/
|
|
@@ -23,18 +22,6 @@ export type BiOptions = {
|
|
|
23
22
|
*/
|
|
24
23
|
extendBufferSize?: number;
|
|
25
24
|
};
|
|
26
|
-
export declare function isBuffer(obj: Buffer | Uint8Array): boolean;
|
|
27
|
-
export declare function check_size(_this: BiReader | BiWriter | ReaderBase, write_bytes: number, write_bit?: number, offset?: number): number;
|
|
28
|
-
export declare function buffcheck(obj: Buffer | Uint8Array | ReaderBase): boolean;
|
|
29
|
-
export declare function arraybuffcheck(_this: BiReader | BiWriter | ReaderBase, obj: Buffer | Uint8Array): boolean;
|
|
30
|
-
export declare function extendarray(_this: BiReader | BiWriter | ReaderBase, to_padd: number): void;
|
|
31
|
-
export declare function checkSize(_this: BiReader | BiWriter | ReaderBase, write_bytes: number, write_bit?: number, offset?: number): number;
|
|
32
|
-
export declare function skip(_this: BiReader | BiWriter | ReaderBase, bytes: number, bits?: number): void;
|
|
33
|
-
export declare function align(_this: BiReader | BiWriter | ReaderBase, n: number): void;
|
|
34
|
-
export declare function alignRev(_this: BiReader | BiWriter | ReaderBase, n: number): void;
|
|
35
|
-
export declare function goto(_this: BiReader | BiWriter | ReaderBase, bytes: number, bits?: number): void;
|
|
36
|
-
export declare function remove(_this: BiReader | BiWriter | ReaderBase, startOffset?: number, endOffset?: number, consume?: boolean, remove?: boolean, fillValue?: number): any;
|
|
37
|
-
export declare function addData(_this: BiReader | BiWriter | ReaderBase, data: Buffer | Uint8Array, consume?: boolean, offset?: number, replace?: boolean): void;
|
|
38
25
|
type hexdumpOptions = {
|
|
39
26
|
/**
|
|
40
27
|
* number of bytes to log, default ``192`` or end of data
|
|
@@ -63,61 +50,48 @@ type hexdumpOptions = {
|
|
|
63
50
|
* @param {boolean?} options.supressUnicode - Supress unicode character preview for even columns.
|
|
64
51
|
* @param {boolean?} options.returnString - Returns the hex dump string instead of logging it.
|
|
65
52
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export declare function NOT(_this: BiReader | BiWriter | ReaderBase, start?: number, end?: number, consume?: boolean): any;
|
|
72
|
-
export declare function LSHIFT(_this: BiReader | BiWriter | ReaderBase, shift_key: any, start?: number, end?: number, consume?: boolean): any;
|
|
73
|
-
export declare function RSHIFT(_this: BiReader | BiWriter | ReaderBase, shift_key: any, start?: number, end?: number, consume?: boolean): any;
|
|
74
|
-
export declare function ADD(_this: BiReader | BiWriter | ReaderBase, add_key: any, start?: number, end?: number, consume?: boolean): any;
|
|
75
|
-
export declare function fString(_this: BiReader | BiWriter | ReaderBase, searchString: string): number;
|
|
76
|
-
export declare function fNumber(_this: BiReader | BiWriter | ReaderBase, targetNumber: number, bits: number, unsigned: boolean, endian?: string): number;
|
|
77
|
-
export declare function fHalfFloat(_this: BiReader | BiWriter | ReaderBase, targetNumber: number, endian?: string): number;
|
|
78
|
-
export declare function fFloat(_this: BiReader | BiWriter | ReaderBase, targetNumber: number, endian?: string): number;
|
|
79
|
-
export declare function fBigInt(_this: BiReader | BiWriter | ReaderBase, targetNumber: number, unsigned: boolean, endian?: string): number;
|
|
80
|
-
export declare function fDoubleFloat(_this: BiReader | BiWriter | ReaderBase, targetNumber: number, endian?: string): number;
|
|
81
|
-
export declare function wbit(_this: BiReader | BiWriter | ReaderBase, value: number, bits: number, unsigned?: boolean, endian?: string): void;
|
|
82
|
-
export declare function rbit(_this: BiReader | BiWriter | ReaderBase, bits?: number, unsigned?: boolean, endian?: string): number;
|
|
83
|
-
export declare function wbyte(_this: BiReader | BiWriter | ReaderBase, value: number, unsigned?: boolean): void;
|
|
84
|
-
export declare function rbyte(_this: BiReader | BiWriter | ReaderBase, unsigned?: boolean): number;
|
|
85
|
-
export declare function wint16(_this: BiReader | BiWriter | ReaderBase, value: number, unsigned?: boolean, endian?: string): void;
|
|
86
|
-
export declare function rint16(_this: BiReader | BiWriter | ReaderBase, unsigned?: boolean, endian?: string): number;
|
|
87
|
-
export declare function rhalffloat(_this: BiReader | BiWriter | ReaderBase, endian?: string): number;
|
|
88
|
-
export declare function whalffloat(_this: BiReader | BiWriter | ReaderBase, value: number, endian?: string): void;
|
|
89
|
-
export declare function wint32(_this: BiReader | BiWriter | ReaderBase, value: number, unsigned?: boolean, endian?: string): void;
|
|
90
|
-
export declare function rint32(_this: BiReader | BiWriter | ReaderBase, unsigned?: boolean, endian?: string): number;
|
|
91
|
-
export declare function rfloat(_this: BiReader | BiWriter | ReaderBase, endian?: string): number;
|
|
92
|
-
export declare function wfloat(_this: BiReader | BiWriter | ReaderBase, value: number, endian?: string): void;
|
|
93
|
-
export declare function rint64(_this: BiReader | BiWriter | ReaderBase, unsigned?: boolean, endian?: string): bigint;
|
|
94
|
-
export declare function wint64(_this: BiReader | BiWriter | ReaderBase, value: number, unsigned?: boolean, endian?: string): void;
|
|
95
|
-
export declare function wdfloat(_this: BiReader | BiWriter | ReaderBase, value: number, endian?: string): void;
|
|
96
|
-
export declare function rdfloat(_this: BiReader | BiWriter | ReaderBase, endian?: string): number;
|
|
97
|
-
export declare function rstring(_this: BiReader | BiWriter | ReaderBase, options?: {
|
|
98
|
-
length?: number;
|
|
99
|
-
stringType?: string;
|
|
100
|
-
terminateValue?: number;
|
|
101
|
-
lengthReadSize?: number;
|
|
102
|
-
stripNull?: boolean;
|
|
103
|
-
encoding?: string;
|
|
104
|
-
endian?: string;
|
|
105
|
-
}): string;
|
|
106
|
-
export declare function wstring(_this: BiReader | BiWriter | ReaderBase, string: string, options?: {
|
|
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
|
+
*/
|
|
107
58
|
length?: number;
|
|
108
|
-
|
|
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
|
+
*/
|
|
109
66
|
terminateValue?: number;
|
|
110
|
-
|
|
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
|
+
*/
|
|
111
78
|
stripNull?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* TextEncoder accepted types
|
|
81
|
+
*/
|
|
112
82
|
encoding?: string;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
83
|
+
/**
|
|
84
|
+
* for wide-pascal and utf-16
|
|
85
|
+
*/
|
|
86
|
+
endian?: "big" | "little";
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
declare class BiBase {
|
|
116
90
|
/**
|
|
117
91
|
* Endianness of default read.
|
|
118
|
-
* @type {
|
|
92
|
+
* @type {endian}
|
|
119
93
|
*/
|
|
120
|
-
endian:
|
|
94
|
+
endian: endian;
|
|
121
95
|
/**
|
|
122
96
|
* Current read byte location.
|
|
123
97
|
*/
|
|
@@ -157,6 +131,16 @@ export declare class ReaderBase {
|
|
|
157
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.
|
|
158
132
|
*/
|
|
159
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);
|
|
160
144
|
isBufferOrUint8Array(obj: Buffer | Uint8Array): boolean;
|
|
161
145
|
extendArray(to_padd: number): void;
|
|
162
146
|
/**
|
|
@@ -165,9 +149,9 @@ export declare class ReaderBase {
|
|
|
165
149
|
*
|
|
166
150
|
* Can be changed at any time, doesn't loose position.
|
|
167
151
|
*
|
|
168
|
-
* @param {
|
|
152
|
+
* @param {endian} endian - endianness ``big`` or ``little``
|
|
169
153
|
*/
|
|
170
|
-
endianness(endian:
|
|
154
|
+
endianness(endian: endian): void;
|
|
171
155
|
/**
|
|
172
156
|
* Sets endian to big.
|
|
173
157
|
*/
|
|
@@ -430,9 +414,9 @@ export declare class ReaderBase {
|
|
|
430
414
|
*
|
|
431
415
|
* @param {number} value - Number to search for.
|
|
432
416
|
* @param {boolean} unsigned - If the number is unsigned (default true)
|
|
433
|
-
* @param {
|
|
417
|
+
* @param {endian} endian - endianness of value (default set endian).
|
|
434
418
|
*/
|
|
435
|
-
findByte(value: number, unsigned?: boolean, endian?:
|
|
419
|
+
findByte(value: number, unsigned?: boolean, endian?: endian): number;
|
|
436
420
|
/**
|
|
437
421
|
* Searches for short value (can be signed or unsigned) position from current read position.
|
|
438
422
|
*
|
|
@@ -442,9 +426,9 @@ export declare class ReaderBase {
|
|
|
442
426
|
*
|
|
443
427
|
* @param {number} value - Number to search for.
|
|
444
428
|
* @param {boolean} unsigned - If the number is unsigned (default true)
|
|
445
|
-
* @param {
|
|
429
|
+
* @param {endian} endian - endianness of value (default set endian).
|
|
446
430
|
*/
|
|
447
|
-
findShort(value: number, unsigned?: boolean, endian?:
|
|
431
|
+
findShort(value: number, unsigned?: boolean, endian?: endian): number;
|
|
448
432
|
/**
|
|
449
433
|
* Searches for integer value (can be signed or unsigned) position from current read position.
|
|
450
434
|
*
|
|
@@ -454,9 +438,9 @@ export declare class ReaderBase {
|
|
|
454
438
|
*
|
|
455
439
|
* @param {number} value - Number to search for.
|
|
456
440
|
* @param {boolean} unsigned - If the number is unsigned (default true)
|
|
457
|
-
* @param {
|
|
441
|
+
* @param {endian} endian - endianness of value (default set endian).
|
|
458
442
|
*/
|
|
459
|
-
findInt(value: number, unsigned?: boolean, endian?:
|
|
443
|
+
findInt(value: number, unsigned?: boolean, endian?: endian): number;
|
|
460
444
|
/**
|
|
461
445
|
* Searches for 64 bit value (can be signed or unsigned) position from current read position.
|
|
462
446
|
*
|
|
@@ -466,9 +450,9 @@ export declare class ReaderBase {
|
|
|
466
450
|
*
|
|
467
451
|
* @param {number} value - Number to search for.
|
|
468
452
|
* @param {boolean} unsigned - If the number is unsigned (default true)
|
|
469
|
-
* @param {
|
|
453
|
+
* @param {endian} endian - endianness of value (default set endian).
|
|
470
454
|
*/
|
|
471
|
-
findInt64(value: number, unsigned?: boolean, endian?:
|
|
455
|
+
findInt64(value: number, unsigned?: boolean, endian?: endian): number;
|
|
472
456
|
/**
|
|
473
457
|
* Searches for half float value position from current read position.
|
|
474
458
|
*
|
|
@@ -477,9 +461,9 @@ export declare class ReaderBase {
|
|
|
477
461
|
* Does not change current read position.
|
|
478
462
|
*
|
|
479
463
|
* @param {number} value - Number to search for.
|
|
480
|
-
* @param {
|
|
464
|
+
* @param {endian} endian - endianness of value (default set endian).
|
|
481
465
|
*/
|
|
482
|
-
findHalfFloat(value: number, endian?:
|
|
466
|
+
findHalfFloat(value: number, endian?: endian): number;
|
|
483
467
|
/**
|
|
484
468
|
* Searches for float value position from current read position.
|
|
485
469
|
*
|
|
@@ -488,9 +472,9 @@ export declare class ReaderBase {
|
|
|
488
472
|
* Does not change current read position.
|
|
489
473
|
*
|
|
490
474
|
* @param {number} value - Number to search for.
|
|
491
|
-
* @param {
|
|
475
|
+
* @param {endian} endian - endianness of value (default set endian).
|
|
492
476
|
*/
|
|
493
|
-
findFloat(value: number, endian?:
|
|
477
|
+
findFloat(value: number, endian?: endian): number;
|
|
494
478
|
/**
|
|
495
479
|
* Searches for double float value position from current read position.
|
|
496
480
|
*
|
|
@@ -499,9 +483,9 @@ export declare class ReaderBase {
|
|
|
499
483
|
* Does not change current read position.
|
|
500
484
|
*
|
|
501
485
|
* @param {number} value - Number to search for.
|
|
502
|
-
* @param {
|
|
486
|
+
* @param {endian} endian - endianness of value (default set endian).
|
|
503
487
|
*/
|
|
504
|
-
findDoubleFloat(value: number, endian?:
|
|
488
|
+
findDoubleFloat(value: number, endian?: endian): number;
|
|
505
489
|
/**
|
|
506
490
|
* Aligns current byte position.
|
|
507
491
|
*
|
|
@@ -651,7 +635,7 @@ export declare class ReaderBase {
|
|
|
651
635
|
/**
|
|
652
636
|
* Replaces data in data.
|
|
653
637
|
*
|
|
654
|
-
* Note:
|
|
638
|
+
* Note: Errors on strict mode.
|
|
655
639
|
*
|
|
656
640
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
657
641
|
* @param {boolean} consume - Move current byte position to end of data (default false)
|
|
@@ -661,7 +645,7 @@ export declare class ReaderBase {
|
|
|
661
645
|
/**
|
|
662
646
|
* Replaces data in data.
|
|
663
647
|
*
|
|
664
|
-
* Note:
|
|
648
|
+
* Note: Errors on strict mode.
|
|
665
649
|
*
|
|
666
650
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to replace in data
|
|
667
651
|
* @param {boolean} consume - Move current byte position to end of data (default false)
|
|
@@ -721,7 +705,7 @@ export declare class ReaderBase {
|
|
|
721
705
|
/**
|
|
722
706
|
* Inserts data into data.
|
|
723
707
|
*
|
|
724
|
-
* Note:
|
|
708
|
+
* Note: Errors on strict mode.
|
|
725
709
|
*
|
|
726
710
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
727
711
|
* @param {boolean} consume - Move current byte position to end of data (default false)
|
|
@@ -731,7 +715,7 @@ export declare class ReaderBase {
|
|
|
731
715
|
/**
|
|
732
716
|
* Inserts data into data.
|
|
733
717
|
*
|
|
734
|
-
* Note:
|
|
718
|
+
* Note: Errors on strict mode.
|
|
735
719
|
*
|
|
736
720
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
737
721
|
* @param {boolean} consume - Move current byte position to end of data (default false)
|
|
@@ -741,7 +725,7 @@ export declare class ReaderBase {
|
|
|
741
725
|
/**
|
|
742
726
|
* Adds data to start of supplied data.
|
|
743
727
|
*
|
|
744
|
-
* Note:
|
|
728
|
+
* Note: Errors on strict mode.
|
|
745
729
|
*
|
|
746
730
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
747
731
|
* @param {boolean} consume - Move current write position to end of data (default false)
|
|
@@ -750,7 +734,7 @@ export declare class ReaderBase {
|
|
|
750
734
|
/**
|
|
751
735
|
* Adds data to start of supplied data.
|
|
752
736
|
*
|
|
753
|
-
* Note:
|
|
737
|
+
* Note: Errors on strict mode.
|
|
754
738
|
*
|
|
755
739
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
756
740
|
* @param {boolean} consume - Move current write position to end of data (default false)
|
|
@@ -759,7 +743,7 @@ export declare class ReaderBase {
|
|
|
759
743
|
/**
|
|
760
744
|
* Adds data to end of supplied data.
|
|
761
745
|
*
|
|
762
|
-
* Note:
|
|
746
|
+
* Note: Errors on strict mode.
|
|
763
747
|
*
|
|
764
748
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
765
749
|
* @param {boolean} consume - Move current write position to end of data (default false)
|
|
@@ -768,7 +752,7 @@ export declare class ReaderBase {
|
|
|
768
752
|
/**
|
|
769
753
|
* Adds data to end of supplied data.
|
|
770
754
|
*
|
|
771
|
-
* Note:
|
|
755
|
+
* Note: Errors on strict mode.
|
|
772
756
|
*
|
|
773
757
|
* @param {Buffer|Uint8Array} data - ``Uint8Array`` or ``Buffer`` to add to data
|
|
774
758
|
* @param {boolean} consume - Move current write position to end of data (default false)
|
|
@@ -900,9 +884,9 @@ export declare class ReaderBase {
|
|
|
900
884
|
* @param {number} value - value as int
|
|
901
885
|
* @param {number} bits - number of bits to write
|
|
902
886
|
* @param {boolean} unsigned - if value is unsigned
|
|
903
|
-
* @param {
|
|
887
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
904
888
|
*/
|
|
905
|
-
writeBit(value: number, bits: number, unsigned?: boolean, endian?:
|
|
889
|
+
writeBit(value: number, bits: number, unsigned?: boolean, endian?: endian): void;
|
|
906
890
|
/**
|
|
907
891
|
* Bit field writer.
|
|
908
892
|
*
|
|
@@ -952,10 +936,10 @@ export declare class ReaderBase {
|
|
|
952
936
|
*
|
|
953
937
|
* @param {number} bits - bits to read
|
|
954
938
|
* @param {boolean} unsigned - if the value is unsigned
|
|
955
|
-
* @param {
|
|
939
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
956
940
|
* @returns {number}
|
|
957
941
|
*/
|
|
958
|
-
readBit(bits?: number, unsigned?: boolean, endian?:
|
|
942
|
+
readBit(bits?: number, unsigned?: boolean, endian?: endian): number;
|
|
959
943
|
/**
|
|
960
944
|
* Bit field reader.
|
|
961
945
|
*
|
|
@@ -1039,25 +1023,25 @@ export declare class ReaderBase {
|
|
|
1039
1023
|
* Read short.
|
|
1040
1024
|
*
|
|
1041
1025
|
* @param {boolean} unsigned - if value is unsigned or not
|
|
1042
|
-
* @param {
|
|
1026
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1043
1027
|
* @returns {number}
|
|
1044
1028
|
*/
|
|
1045
|
-
readInt16(unsigned?: boolean, endian?:
|
|
1029
|
+
readInt16(unsigned?: boolean, endian?: endian): number;
|
|
1046
1030
|
/**
|
|
1047
1031
|
* Write int16.
|
|
1048
1032
|
*
|
|
1049
1033
|
* @param {number} value - value as int
|
|
1050
1034
|
* @param {boolean} unsigned - if the value is unsigned
|
|
1051
|
-
* @param {
|
|
1035
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1052
1036
|
*/
|
|
1053
|
-
writeInt16(value: number, unsigned?: boolean, endian?:
|
|
1037
|
+
writeInt16(value: number, unsigned?: boolean, endian?: endian): void;
|
|
1054
1038
|
/**
|
|
1055
1039
|
* Write unsigned int16.
|
|
1056
1040
|
*
|
|
1057
1041
|
* @param {number} value - value as int
|
|
1058
|
-
* @param {
|
|
1042
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1059
1043
|
*/
|
|
1060
|
-
writeUInt16(value: number, endian?:
|
|
1044
|
+
writeUInt16(value: number, endian?: endian): void;
|
|
1061
1045
|
/**
|
|
1062
1046
|
* Write unsigned int16.
|
|
1063
1047
|
*
|
|
@@ -1079,11 +1063,11 @@ export declare class ReaderBase {
|
|
|
1079
1063
|
/**
|
|
1080
1064
|
* Read unsigned short.
|
|
1081
1065
|
*
|
|
1082
|
-
* @param {
|
|
1066
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1083
1067
|
*
|
|
1084
1068
|
* @returns {number}
|
|
1085
1069
|
*/
|
|
1086
|
-
readUInt16(endian?:
|
|
1070
|
+
readUInt16(endian?: endian): number;
|
|
1087
1071
|
/**
|
|
1088
1072
|
* Read unsigned short in little endian.
|
|
1089
1073
|
*
|
|
@@ -1111,17 +1095,17 @@ export declare class ReaderBase {
|
|
|
1111
1095
|
/**
|
|
1112
1096
|
* Read half float.
|
|
1113
1097
|
*
|
|
1114
|
-
* @param {
|
|
1098
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1115
1099
|
* @returns {number}
|
|
1116
1100
|
*/
|
|
1117
|
-
readHalfFloat(endian?:
|
|
1101
|
+
readHalfFloat(endian?: endian): number;
|
|
1118
1102
|
/**
|
|
1119
1103
|
* Writes half float.
|
|
1120
1104
|
*
|
|
1121
1105
|
* @param {number} value - value as int
|
|
1122
|
-
* @param {
|
|
1106
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1123
1107
|
*/
|
|
1124
|
-
writeHalfFloat(value: number, endian?:
|
|
1108
|
+
writeHalfFloat(value: number, endian?: endian): void;
|
|
1125
1109
|
/**
|
|
1126
1110
|
* Writes half float.
|
|
1127
1111
|
*
|
|
@@ -1150,25 +1134,25 @@ export declare class ReaderBase {
|
|
|
1150
1134
|
* Read 32 bit integer.
|
|
1151
1135
|
*
|
|
1152
1136
|
* @param {boolean} unsigned - if value is unsigned or not
|
|
1153
|
-
* @param {
|
|
1137
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1154
1138
|
* @returns {number}
|
|
1155
1139
|
*/
|
|
1156
|
-
readInt32(unsigned?: boolean, endian?:
|
|
1140
|
+
readInt32(unsigned?: boolean, endian?: endian): number;
|
|
1157
1141
|
/**
|
|
1158
1142
|
* Write int32.
|
|
1159
1143
|
*
|
|
1160
1144
|
* @param {number} value - value as int
|
|
1161
1145
|
* @param {boolean} unsigned - if the value is unsigned
|
|
1162
|
-
* @param {
|
|
1146
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1163
1147
|
*/
|
|
1164
|
-
writeInt32(value: number, unsigned?: boolean, endian?:
|
|
1148
|
+
writeInt32(value: number, unsigned?: boolean, endian?: endian): void;
|
|
1165
1149
|
/**
|
|
1166
1150
|
* Write unsigned int32.
|
|
1167
1151
|
*
|
|
1168
1152
|
* @param {number} value - value as int
|
|
1169
|
-
* @param {
|
|
1153
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1170
1154
|
*/
|
|
1171
|
-
writeUInt32(value: number, endian?:
|
|
1155
|
+
writeUInt32(value: number, endian?: endian): void;
|
|
1172
1156
|
/**
|
|
1173
1157
|
* Write signed int32.
|
|
1174
1158
|
*
|
|
@@ -1220,17 +1204,17 @@ export declare class ReaderBase {
|
|
|
1220
1204
|
/**
|
|
1221
1205
|
* Read float.
|
|
1222
1206
|
*
|
|
1223
|
-
* @param {
|
|
1207
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1224
1208
|
* @returns {number}
|
|
1225
1209
|
*/
|
|
1226
|
-
readFloat(endian?:
|
|
1210
|
+
readFloat(endian?: endian): number;
|
|
1227
1211
|
/**
|
|
1228
1212
|
* Write float.
|
|
1229
1213
|
*
|
|
1230
1214
|
* @param {number} value - value as int
|
|
1231
|
-
* @param {
|
|
1215
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1232
1216
|
*/
|
|
1233
|
-
writeFloat(value: number, endian?:
|
|
1217
|
+
writeFloat(value: number, endian?: endian): void;
|
|
1234
1218
|
/**
|
|
1235
1219
|
* Write float.
|
|
1236
1220
|
*
|
|
@@ -1259,25 +1243,25 @@ export declare class ReaderBase {
|
|
|
1259
1243
|
* Read signed 64 bit integer.
|
|
1260
1244
|
*
|
|
1261
1245
|
* @param {boolean} unsigned - if value is unsigned or not
|
|
1262
|
-
* @param {
|
|
1246
|
+
* @param {endian?} endian - ``big`` or ``little``
|
|
1263
1247
|
* @returns {number}
|
|
1264
1248
|
*/
|
|
1265
|
-
readInt64(unsigned?: boolean, endian?:
|
|
1249
|
+
readInt64(unsigned?: boolean, endian?: endian): bigint;
|
|
1266
1250
|
/**
|
|
1267
1251
|
* Write 64 bit integer.
|
|
1268
1252
|
*
|
|
1269
1253
|
* @param {number} value - value as int
|
|
1270
1254
|
* @param {boolean} unsigned - if the value is unsigned
|
|
1271
|
-
* @param {
|
|
1255
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1272
1256
|
*/
|
|
1273
|
-
writeInt64(value: number, unsigned?: boolean, endian?:
|
|
1257
|
+
writeInt64(value: number, unsigned?: boolean, endian?: endian): void;
|
|
1274
1258
|
/**
|
|
1275
1259
|
* Write unsigned 64 bit integer.
|
|
1276
1260
|
*
|
|
1277
1261
|
* @param {number} value - value as int
|
|
1278
|
-
* @param {
|
|
1262
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1279
1263
|
*/
|
|
1280
|
-
writeUInt64(value: number, endian?:
|
|
1264
|
+
writeUInt64(value: number, endian?: endian): void;
|
|
1281
1265
|
/**
|
|
1282
1266
|
* Write signed 64 bit integer.
|
|
1283
1267
|
*
|
|
@@ -1335,17 +1319,17 @@ export declare class ReaderBase {
|
|
|
1335
1319
|
/**
|
|
1336
1320
|
* Read double float.
|
|
1337
1321
|
*
|
|
1338
|
-
* @param {
|
|
1322
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1339
1323
|
* @returns {number}
|
|
1340
1324
|
*/
|
|
1341
|
-
readDoubleFloat(endian?:
|
|
1325
|
+
readDoubleFloat(endian?: endian): number;
|
|
1342
1326
|
/**
|
|
1343
1327
|
* Writes double float.
|
|
1344
1328
|
*
|
|
1345
1329
|
* @param {number} value - value as int
|
|
1346
|
-
* @param {
|
|
1330
|
+
* @param {endian} endian - ``big`` or ``little``
|
|
1347
1331
|
*/
|
|
1348
|
-
writeDoubleFloat(value: number, endian?:
|
|
1332
|
+
writeDoubleFloat(value: number, endian?: endian): void;
|
|
1349
1333
|
/**
|
|
1350
1334
|
* Writes double float.
|
|
1351
1335
|
*
|
|
@@ -1373,55 +1357,110 @@ export declare class ReaderBase {
|
|
|
1373
1357
|
/**
|
|
1374
1358
|
* Reads string, use options object for different types.
|
|
1375
1359
|
*
|
|
1376
|
-
* @param {
|
|
1377
|
-
*
|
|
1378
|
-
* {
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1381
|
-
*
|
|
1382
|
-
*
|
|
1383
|
-
*
|
|
1384
|
-
* encoding: "utf-8", //TextEncoder accepted types
|
|
1385
|
-
* endian: "little", //for wide-pascal and utf-16
|
|
1386
|
-
* }
|
|
1387
|
-
* ```
|
|
1388
|
-
* @return string
|
|
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>}
|
|
1389
1368
|
*/
|
|
1390
|
-
readString(options?:
|
|
1391
|
-
length?: number;
|
|
1392
|
-
stringType?: string;
|
|
1393
|
-
terminateValue?: number;
|
|
1394
|
-
lengthReadSize?: number;
|
|
1395
|
-
stripNull?: boolean;
|
|
1396
|
-
encoding?: string;
|
|
1397
|
-
endian?: string;
|
|
1398
|
-
}): string;
|
|
1369
|
+
readString(options?: stringOptions): string;
|
|
1399
1370
|
/**
|
|
1400
1371
|
* Writes string, use options object for different types.
|
|
1401
1372
|
*
|
|
1402
|
-
*
|
|
1403
1373
|
* @param {string} string - text string
|
|
1404
|
-
* @param {
|
|
1405
|
-
*
|
|
1406
|
-
* {
|
|
1407
|
-
*
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
* encoding: "utf-8", //TextEncoder accepted types
|
|
1412
|
-
* endian: "little", //for wide-pascal and utf-16
|
|
1413
|
-
* }
|
|
1414
|
-
* ```
|
|
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
|
|
1415
1381
|
*/
|
|
1416
|
-
writeString(string: string, options?:
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1382
|
+
writeString(string: string, options?: stringOptions): void;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
interface BinaryAliasReader extends BiBase {
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
declare const BiReaderBase: typeof BiBase;
|
|
1389
|
+
/**
|
|
1390
|
+
* Binary reader, includes bitfields and strings.
|
|
1391
|
+
*
|
|
1392
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
|
|
1393
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
1394
|
+
* @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
|
|
1395
|
+
* @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
|
|
1396
|
+
* @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
1397
|
+
* @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
|
|
1398
|
+
* @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``.
|
|
1399
|
+
*
|
|
1400
|
+
* @since 2.0
|
|
1401
|
+
*/
|
|
1402
|
+
declare class BiReader extends BiReaderBase implements BinaryAliasReader {
|
|
1403
|
+
/**
|
|
1404
|
+
* Binary reader, includes bitfields and strings.
|
|
1405
|
+
*
|
|
1406
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiReader.data``
|
|
1407
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
1408
|
+
* @param {number?} options.byteOffset - Byte offset to start reader (default ``0``)
|
|
1409
|
+
* @param {number?} options.bitOffset - Bit offset 0-7 to start reader (default ``0``)
|
|
1410
|
+
* @param {string?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
1411
|
+
* @param {boolean?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``true``)
|
|
1412
|
+
* @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``.
|
|
1413
|
+
*/
|
|
1414
|
+
constructor(data: Buffer | Uint8Array, options?: BiOptions);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
interface BinaryAliasWriter extends BiBase {
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
declare const BiWriterBase: typeof BiBase;
|
|
1421
|
+
/**
|
|
1422
|
+
* Binary writer, includes bitfields and strings.
|
|
1423
|
+
*
|
|
1424
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
|
|
1425
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
1426
|
+
* @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
|
|
1427
|
+
* @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
|
|
1428
|
+
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
1429
|
+
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
1430
|
+
* @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``.
|
|
1431
|
+
*
|
|
1432
|
+
* @since 2.0
|
|
1433
|
+
*/
|
|
1434
|
+
declare class BiWriter extends BiWriterBase implements BinaryAliasWriter {
|
|
1435
|
+
/**
|
|
1436
|
+
* Binary writer, includes bitfields and strings.
|
|
1437
|
+
*
|
|
1438
|
+
* @param {Buffer|Uint8Array} data - ``Buffer`` or ``Uint8Array``. Always found in ``BiWriter.data``
|
|
1439
|
+
* @param {BiOptions?} options - Any options to set at start
|
|
1440
|
+
* @param {BiOptions["byteOffset"]?} options.byteOffset - Byte offset to start writer (default ``0``)
|
|
1441
|
+
* @param {BiOptions["bitOffset"]?} options.bitOffset - Bit offset 0-7 to start writer (default ``0``)
|
|
1442
|
+
* @param {BiOptions["endianness"]?} options.endianness - Endianness ``big`` or ``little`` (default ``little``)
|
|
1443
|
+
* @param {BiOptions["strict"]?} options.strict - Strict mode: if ``true`` does not extend supplied array on outside write (default ``false``)
|
|
1444
|
+
* @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``.
|
|
1445
|
+
*/
|
|
1446
|
+
constructor(data?: Buffer | Uint8Array, options?: BiOptions);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* Not in use anymore.
|
|
1451
|
+
* @since 3.0
|
|
1452
|
+
* @deprecated Use ``BiReader`` instead.
|
|
1453
|
+
*/
|
|
1454
|
+
declare class bireader {
|
|
1455
|
+
constructor();
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* Not in use anymore.
|
|
1459
|
+
* @since 3.0
|
|
1460
|
+
* @deprecated Use ``BiWriter`` instead.
|
|
1461
|
+
*/
|
|
1462
|
+
declare class biwriter {
|
|
1463
|
+
constructor();
|
|
1425
1464
|
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1465
|
+
|
|
1466
|
+
export { BiReader, BiWriter, bireader, biwriter, hexdump };
|