pw-js-world 0.1.4-dev.e52001b → 0.1.5-dev.415d227

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,324 +0,0 @@
1
- /**
2
- * CREDIT: Anatoly for making this Buffer Reader so I don't have to!
3
- * Source: https://github.com/Anatoly03/pixelwalker.js/blob/9bb3c7e39a45006086a2abae8c515599bd3db835/src/util/buffer-reader.ts
4
- * License: ISC
5
- */
6
- /**
7
- * Data during the communication in the process is dynamic
8
- * typed. Every entry is followed by a byte identifying the
9
- * type, followed by data. The type header is noted by its'
10
- * 7-bit notation.
11
- */
12
- export declare enum ComponentTypeHeader {
13
- String = 0,
14
- Byte = 1,
15
- Int16 = 2,
16
- Int32 = 3,
17
- Int64 = 4,
18
- Float = 5,
19
- Double = 6,
20
- Boolean = 7,
21
- ByteArray = 8
22
- }
23
- /**
24
- * A Buffer reader is a special buffer extension made to perform
25
- * game-specific tasks in the field of communication.
26
- *
27
- * @implements Buffer
28
- */
29
- export default class BufferReader {
30
- private buffer;
31
- private offset;
32
- /**
33
- *
34
- */
35
- private constructor();
36
- /**
37
- *
38
- */
39
- static from(from: Uint8Array | Buffer): BufferReader;
40
- /**
41
- *
42
- */
43
- static alloc(amount: number): BufferReader;
44
- /**
45
- * @param {string} value
46
- * @returns {Buffer}
47
- */
48
- static String(value?: string): Buffer;
49
- /**
50
- * @param {number} value
51
- * @returns {Buffer}
52
- */
53
- static Byte(value?: number): Buffer;
54
- /**
55
- * @param {number} value
56
- * @returns {Buffer}
57
- */
58
- static Int16(value?: number): Buffer;
59
- /**
60
- * @param {number} value
61
- * @returns {Buffer}
62
- */
63
- static Int32(value?: number): Buffer;
64
- /**
65
- * @param {bigint} value
66
- * @returns {Buffer}
67
- */
68
- static Int64(value?: bigint): Buffer;
69
- /**
70
- * @param {number} value
71
- * @returns {Buffer}
72
- */
73
- static Float(value?: number): Buffer;
74
- /**
75
- * @param {number} value
76
- * @returns {Buffer}
77
- */
78
- static Double(value?: number): Buffer;
79
- /**
80
- * @param {boolean} value
81
- * @returns {Buffer}
82
- */
83
- static Boolean(value?: boolean): Buffer;
84
- /**
85
- * @param {Uint8Array} buffer
86
- * @returns {Buffer}
87
- */
88
- static ByteArray(buffer?: Buffer): Buffer;
89
- /**
90
- * @param {number} value
91
- * @returns {Buffer}
92
- */
93
- static Magic(value: number): Buffer;
94
- /**
95
- * @param {number} value
96
- * @returns {Buffer}
97
- */
98
- static Bit7(value?: number): Buffer;
99
- /**
100
- * @param tt
101
- * @param value
102
- */
103
- static Dynamic(tt: ComponentTypeHeader, value: boolean | number | bigint | string | Buffer): Buffer;
104
- /**
105
- *
106
- */
107
- get length(): number;
108
- /**
109
- *
110
- */
111
- subarray(start?: number, end?: number): BufferReader;
112
- /**
113
- *
114
- */
115
- write(value: string): number;
116
- /**
117
- *
118
- */
119
- writeBigInt64BE(value: bigint): number;
120
- /**
121
- *
122
- */
123
- writeBigInt64LE(value: bigint): number;
124
- /**
125
- *
126
- */
127
- writeUInt8(value: number): number;
128
- /**
129
- *
130
- */
131
- writeUInt16LE(value: number): number;
132
- /**
133
- *
134
- */
135
- writeUInt16BE(value: number): number;
136
- /**
137
- *
138
- */
139
- writeUInt32LE(value: number): number;
140
- /**
141
- *
142
- */
143
- writeUInt32BE(value: number): number;
144
- /**
145
- *
146
- */
147
- writeInt8(value: number): number;
148
- /**
149
- *
150
- */
151
- writeInt16LE(value: number): number;
152
- /**
153
- *
154
- */
155
- writeInt16BE(value: number): number;
156
- /**
157
- *
158
- */
159
- writeInt32LE(value: number): number;
160
- /**
161
- *
162
- */
163
- writeInt32BE(value: number): number;
164
- /**
165
- *
166
- */
167
- writeFloatLE(value: number): number;
168
- /**
169
- *
170
- */
171
- writeFloatBE(value: number): number;
172
- /**
173
- *
174
- */
175
- writeDoubleLE(value: number): number;
176
- /**
177
- *
178
- */
179
- writeDoubleBE(value: number): number;
180
- /**
181
- *
182
- */
183
- readBigUInt64BE(): bigint;
184
- /**
185
- *
186
- */
187
- readBigUInt64LE(): bigint;
188
- /**
189
- *
190
- */
191
- readBigInt64BE(): bigint;
192
- /**
193
- *
194
- */
195
- readBigInt64LE(): bigint;
196
- /**
197
- *
198
- */
199
- expectUInt8(value: number): number;
200
- /**
201
- *
202
- */
203
- readUInt8(): number;
204
- /**
205
- *
206
- */
207
- readUInt16LE(): number;
208
- /**
209
- *
210
- */
211
- readUInt16BE(): number;
212
- /**
213
- *
214
- */
215
- readUInt32LE(): number;
216
- /**
217
- *
218
- */
219
- readUInt32BE(): number;
220
- /**
221
- *
222
- */
223
- readInt8(): number;
224
- /**
225
- *
226
- */
227
- readInt16LE(): number;
228
- /**
229
- *
230
- */
231
- readInt16BE(): number;
232
- /**
233
- *
234
- */
235
- readInt32LE(): number;
236
- /**
237
- *
238
- */
239
- readInt32BE(): number;
240
- /**
241
- *
242
- */
243
- readFloatLE(): number;
244
- /**
245
- *
246
- */
247
- readFloatBE(): number;
248
- /**
249
- *
250
- */
251
- readDoubleLE(): number;
252
- /**
253
- *
254
- */
255
- readDoubleBE(): number;
256
- read(tt: ComponentTypeHeader, littleEndian?: boolean): string | number | bigint | boolean | Buffer;
257
- read(tt: ComponentTypeHeader.String, littleEndian?: boolean): string;
258
- read(tt: ComponentTypeHeader.Byte, littleEndian?: boolean): number;
259
- read(tt: ComponentTypeHeader.Int16, littleEndian?: boolean): number;
260
- read(tt: ComponentTypeHeader.Int32, littleEndian?: boolean): number;
261
- read(tt: ComponentTypeHeader.Int64, littleEndian?: boolean): bigint;
262
- read(tt: ComponentTypeHeader.Float, littleEndian?: boolean): number;
263
- read(tt: ComponentTypeHeader.Double, littleEndian?: boolean): number;
264
- read(tt: ComponentTypeHeader.Boolean, littleEndian?: boolean): boolean;
265
- read(tt: ComponentTypeHeader.ByteArray, littleEndian?: boolean): Buffer;
266
- /**
267
- *
268
- */
269
- toBuffer(): Buffer;
270
- /**
271
- * https://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer
272
- */
273
- toArrayBuffer(): ArrayBuffer;
274
- /**
275
- *
276
- */
277
- at(idx: number): number;
278
- /**
279
- * Advanced the buffer reader by pffset.
280
- */
281
- advanceOffset(relativeOffset?: number): this;
282
- /**
283
- * This function reads how many bytes a normal integer would take
284
- * as a 7-bit number
285
- *
286
- * 1(000 0001) 0(111 1110)
287
- */
288
- static length7BitInt(value: number): number;
289
- /**
290
- * Reads in an integer in 7-bit notation. A 7-bit integer
291
- * encoding splits a number into a variable size of bits,
292
- * in which the first bit is set while bytes are following.
293
- *
294
- * @example
295
- *
296
- * ```
297
- * 1111 0000 1010 1010 1000 0000 0000 0001 Reading In
298
- * ^--- ---- ^--- ---- ^--- ---- ^--- ----
299
- * 111 0000 010 1010 000 0000 000 0001 Writing Out
300
- * ```
301
- */
302
- read7BitInt(): number;
303
- /**
304
- * Write a normal integer value into buffer at offset.
305
- */
306
- write7BitInt(value: number): void;
307
- /**
308
- * Reads a dynamic buffer which is prepended by its' length
309
- * in 7-bit encoding.
310
- */
311
- readDynamicBuffer(): Buffer<ArrayBufferLike>;
312
- /**
313
- * Append a buffer to the current buffer. Asserts the cursor
314
- * to be at the end of the current buffer.
315
- */
316
- append(buffer: Buffer): this;
317
- /**
318
- * Keep Deserializing the buffer for typed data until
319
- * you reach the end of the buffer. Typed data consists
320
- * of a type indicator in 7-bit-encoding and data following
321
- * accordingly.
322
- */
323
- deserialize(): (string | number | bigint | boolean | Buffer<ArrayBufferLike>)[];
324
- }