@jsprismarine/binaryutils 0.15.0-unstable-20261024002035
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/CHANGELOG.md +24 -0
- package/LICENSE +373 -0
- package/README.md +186 -0
- package/dist/BinaryStream.cjs.cjs +839 -0
- package/dist/BinaryStream.d.ts +488 -0
- package/dist/BinaryStream.d.ts.map +1 -0
- package/dist/BinaryStream.es.js +831 -0
- package/dist/_virtual/_rolldown/runtime.cjs.cjs +24 -0
- package/dist/index.cjs.cjs +8 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +2 -0
- package/package.json +69 -0
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A high-performance binary stream for reading and writing binary data.
|
|
3
|
+
*
|
|
4
|
+
* Unlike Node.js native buffers which have fixed size, BinaryStream uses dynamic
|
|
5
|
+
* buffers that grow automatically during write operations. This eliminates the need
|
|
6
|
+
* for manual resizing or inefficient `Buffer.concat()` calls.
|
|
7
|
+
*
|
|
8
|
+
* @example Reading data
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const stream = new BinaryStream(buffer);
|
|
11
|
+
* const value = stream.readInt();
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @example Writing data
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const stream = new BinaryStream();
|
|
17
|
+
* stream.writeInt(42);
|
|
18
|
+
* stream.write(Buffer.from('Hello')); // Buffer grows automatically
|
|
19
|
+
* const buffer = stream.getWriteBuffer();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example Encoding many packets without allocating
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const stream = new BinaryStream(undefined, 0, 4096);
|
|
25
|
+
* for (const packet of queue) {
|
|
26
|
+
* stream.resetWrite();
|
|
27
|
+
* packet.encode(stream);
|
|
28
|
+
* offset = stream.copyInto(arena, offset);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class BinaryStream {
|
|
33
|
+
private writeBuffer;
|
|
34
|
+
private readBuffer;
|
|
35
|
+
private readIndex;
|
|
36
|
+
private writeIndex;
|
|
37
|
+
private writeCapacity;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new BinaryStream instance.
|
|
40
|
+
* @param {Buffer|null|undefined} buffer - The array or Buffer containing binary data.
|
|
41
|
+
* @param {number} offset - The initial pointer position.
|
|
42
|
+
* @param {number} initialCapacity - Pre-allocates the write buffer to this size. Use it when
|
|
43
|
+
* the encoded size is known up front: it skips the 256 -> 512 -> 1024 ... growth ladder, and
|
|
44
|
+
* with {@link resetWrite} it lets a long-lived encoder run without allocating at all.
|
|
45
|
+
*/
|
|
46
|
+
constructor(buffer?: Buffer, offset?: number, initialCapacity?: number);
|
|
47
|
+
/**
|
|
48
|
+
* Reads a slice of buffer by the given length.
|
|
49
|
+
* @param {number} len
|
|
50
|
+
*/
|
|
51
|
+
read(len: number): Buffer;
|
|
52
|
+
/**
|
|
53
|
+
* Appends a buffer to the main buffer.
|
|
54
|
+
* @param {Buffer|Uint8Array} buf
|
|
55
|
+
*/
|
|
56
|
+
write(buf: Uint8Array): void;
|
|
57
|
+
/**
|
|
58
|
+
* Reads an unsigned byte (0 to 255).
|
|
59
|
+
* @returns {number}
|
|
60
|
+
*/
|
|
61
|
+
readByte(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Writes an unsigned byte (0 to 255).
|
|
64
|
+
* @param {number} v
|
|
65
|
+
*/
|
|
66
|
+
writeByte(v: number): void;
|
|
67
|
+
/**
|
|
68
|
+
* Reads a signed byte (-128 to 127).
|
|
69
|
+
* @returns {number}
|
|
70
|
+
*/
|
|
71
|
+
readSignedByte(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Writes a signed byte (-128 to 127).
|
|
74
|
+
* @param {number} v
|
|
75
|
+
*/
|
|
76
|
+
writeSignedByte(v: number): void;
|
|
77
|
+
/**
|
|
78
|
+
* Reads a boolean (true or false).
|
|
79
|
+
* @returns {boolean}
|
|
80
|
+
*/
|
|
81
|
+
readBoolean(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Writes a boolean (true or false).
|
|
84
|
+
* @param {boolean} v
|
|
85
|
+
*/
|
|
86
|
+
writeBoolean(v: boolean): void;
|
|
87
|
+
/**
|
|
88
|
+
* Reads a 16 bit (2 bytes) signed big-endian number.
|
|
89
|
+
* @returns {number}
|
|
90
|
+
*/
|
|
91
|
+
readShort(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Writes a 16 bit (2 bytes) signed big-endian number.
|
|
94
|
+
* @param {number} v
|
|
95
|
+
*/
|
|
96
|
+
writeShort(v: number): void;
|
|
97
|
+
/**
|
|
98
|
+
* Reads a 16 bit (2 bytes) signed little-endian number.
|
|
99
|
+
* @returns {number}
|
|
100
|
+
*/
|
|
101
|
+
readShortLE(): number;
|
|
102
|
+
/**
|
|
103
|
+
* Writes a 16 bit (2 bytes) signed little-endian number.
|
|
104
|
+
* @param {number} v
|
|
105
|
+
*/
|
|
106
|
+
writeShortLE(v: number): void;
|
|
107
|
+
/**
|
|
108
|
+
* Reads a 16 bit (2 bytes) unsigned big-endian number.
|
|
109
|
+
* @returns {number}
|
|
110
|
+
*/
|
|
111
|
+
readUnsignedShort(): number;
|
|
112
|
+
/**
|
|
113
|
+
* Writes a 16 bit (2 bytes) unsigned big-endian number.
|
|
114
|
+
* @param {number} v
|
|
115
|
+
*/
|
|
116
|
+
writeUnsignedShort(v: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* Reads a 16 bit (2 bytes) unsigned little-endian number.
|
|
119
|
+
* @returns {number}
|
|
120
|
+
*/
|
|
121
|
+
readUnsignedShortLE(): number;
|
|
122
|
+
/**
|
|
123
|
+
* Writes a 16 bit (2 bytes) unsigned little-endian number.
|
|
124
|
+
* @param {number} v
|
|
125
|
+
*/
|
|
126
|
+
writeUnsignedShortLE(v: number): void;
|
|
127
|
+
/**
|
|
128
|
+
* Reads a 24 bit (3 bytes) signed big-endian number.
|
|
129
|
+
* @returns {number}
|
|
130
|
+
*/
|
|
131
|
+
readTriad(): number;
|
|
132
|
+
/**
|
|
133
|
+
* Writes a 24 bit (3 bytes) signed big-endian number.
|
|
134
|
+
* @param {number} v
|
|
135
|
+
*/
|
|
136
|
+
writeTriad(v: number): void;
|
|
137
|
+
/**
|
|
138
|
+
* Reads a 24 bit (3 bytes) little-endian number.
|
|
139
|
+
* @returns {number}
|
|
140
|
+
*/
|
|
141
|
+
readTriadLE(): number;
|
|
142
|
+
/**
|
|
143
|
+
* Writes a 24 bit (3 bytes) signed little-endian number.
|
|
144
|
+
* @param {number} v
|
|
145
|
+
*/
|
|
146
|
+
writeTriadLE(v: number): void;
|
|
147
|
+
/**
|
|
148
|
+
* Reads a 24 bit (3 bytes) unsigned big-endian number.
|
|
149
|
+
* @returns {number}
|
|
150
|
+
*/
|
|
151
|
+
readUnsignedTriad(): number;
|
|
152
|
+
/**
|
|
153
|
+
* Writes a 24 bit (3 bytes) unsigned big-endian number.
|
|
154
|
+
* @param {number} v
|
|
155
|
+
*/
|
|
156
|
+
writeUnsignedTriad(v: number): void;
|
|
157
|
+
/**
|
|
158
|
+
* Reads a 24 bit (3 bytes) unsigned little-endian number.
|
|
159
|
+
* @returns {number}
|
|
160
|
+
*/
|
|
161
|
+
readUnsignedTriadLE(): number;
|
|
162
|
+
/**
|
|
163
|
+
* Writes a 24 bit (3 bytes) unsigned little-endian number.
|
|
164
|
+
* @param {number} v
|
|
165
|
+
*/
|
|
166
|
+
writeUnsignedTriadLE(v: number): void;
|
|
167
|
+
/**
|
|
168
|
+
* Reads a 32 bit (4 bytes) big-endian signed number.
|
|
169
|
+
* @returns {number}
|
|
170
|
+
*/
|
|
171
|
+
readInt(): number;
|
|
172
|
+
/**
|
|
173
|
+
* Writes a 32 bit (4 bytes) big-endian signed number.
|
|
174
|
+
* @param {number} v
|
|
175
|
+
*/
|
|
176
|
+
writeInt(v: number): void;
|
|
177
|
+
/**
|
|
178
|
+
* Reads a 32 bit (4 bytes) signed number.
|
|
179
|
+
* @returns {number}
|
|
180
|
+
*/
|
|
181
|
+
readIntLE(): number;
|
|
182
|
+
/**
|
|
183
|
+
* Writes a 32 bit (4 bytes) little-endian signed number.
|
|
184
|
+
* @param {number} v
|
|
185
|
+
*/
|
|
186
|
+
writeIntLE(v: number): void;
|
|
187
|
+
/**
|
|
188
|
+
* Reads a 32 bit (4 bytes) big-endian unsigned number.
|
|
189
|
+
* @returns {number}
|
|
190
|
+
*/
|
|
191
|
+
readUnsignedInt(): number;
|
|
192
|
+
/**
|
|
193
|
+
* Writes a 32 bit (4 bytes) big-endian unsigned number.
|
|
194
|
+
* @param {number} v
|
|
195
|
+
*/
|
|
196
|
+
writeUnsignedInt(v: number): void;
|
|
197
|
+
/**
|
|
198
|
+
* Reads a 32 bit (4 bytes) little-endian unsigned number.
|
|
199
|
+
* @returns {number}
|
|
200
|
+
*/
|
|
201
|
+
readUnsignedIntLE(): number;
|
|
202
|
+
/**
|
|
203
|
+
* Writes a 32 bit (4 bytes) little-endian unsigned number.
|
|
204
|
+
* @param {number} v
|
|
205
|
+
*/
|
|
206
|
+
writeUnsignedIntLE(v: number): void;
|
|
207
|
+
/**
|
|
208
|
+
* Returns a 32 bit (4 bytes) big-endian flating point number.
|
|
209
|
+
* @returns {number}
|
|
210
|
+
*/
|
|
211
|
+
readFloat(): number;
|
|
212
|
+
/**
|
|
213
|
+
* Writes a 32 bit (4 bytes) big-endian floating point number.
|
|
214
|
+
* @param {number} v
|
|
215
|
+
*/
|
|
216
|
+
writeFloat(v: number): void;
|
|
217
|
+
/**
|
|
218
|
+
* Returns a 32 bit (4 bytes) big-endian flating point number.
|
|
219
|
+
* @returns {number}
|
|
220
|
+
*/
|
|
221
|
+
readFloatLE(): number;
|
|
222
|
+
/**
|
|
223
|
+
* Writes a 32 bit (4 bytes) little-endian floating point number.
|
|
224
|
+
* @param {number} v
|
|
225
|
+
*/
|
|
226
|
+
writeFloatLE(v: number): void;
|
|
227
|
+
/**
|
|
228
|
+
* Returns a 64 bit (8 bytes) big-endian flating point number.
|
|
229
|
+
* @returns {number}
|
|
230
|
+
*/
|
|
231
|
+
readDouble(): number;
|
|
232
|
+
/**
|
|
233
|
+
* Writes a 64 bit (8 bytes) big-endian floating point number.
|
|
234
|
+
* @param {number} v
|
|
235
|
+
*/
|
|
236
|
+
writeDouble(v: number): void;
|
|
237
|
+
/**
|
|
238
|
+
* Returns a 64 bit (8 bytes) little-endian flating point number.
|
|
239
|
+
* @returns {number}
|
|
240
|
+
*/
|
|
241
|
+
readDoubleLE(): number;
|
|
242
|
+
/**
|
|
243
|
+
* Writes a 64 bit (8 bytes) little-endian floating point number.
|
|
244
|
+
* @param {number} v
|
|
245
|
+
*/
|
|
246
|
+
writeDoubleLE(v: number): void;
|
|
247
|
+
/**
|
|
248
|
+
* Returns a 64 bit (8 bytes) signed big-endian number.
|
|
249
|
+
* @returns {bigint}
|
|
250
|
+
*/
|
|
251
|
+
readLong(): bigint;
|
|
252
|
+
/**
|
|
253
|
+
* Writes a 64 bit (8 bytes) signed big-endian number.
|
|
254
|
+
* @param {bigint} v
|
|
255
|
+
*/
|
|
256
|
+
writeLong(v: bigint): void;
|
|
257
|
+
/**
|
|
258
|
+
* Returns a 64 bit (8 bytes) signed little-endian number.
|
|
259
|
+
* @returns {bigint}
|
|
260
|
+
*/
|
|
261
|
+
readLongLE(): bigint;
|
|
262
|
+
/**
|
|
263
|
+
* Writes a 64 bit (8 bytes) signed little-endian number.
|
|
264
|
+
* @param {bigint} v
|
|
265
|
+
*/
|
|
266
|
+
writeLongLE(v: bigint): void;
|
|
267
|
+
/**
|
|
268
|
+
* Returns a 64 bit (8 bytes) unsigned big-endian number.
|
|
269
|
+
* @returns {bigint}
|
|
270
|
+
*/
|
|
271
|
+
readUnsignedLong(): bigint;
|
|
272
|
+
/**
|
|
273
|
+
* Writes a 64 bit (8 bytes) unsigned big-endian number.
|
|
274
|
+
* @param {bigint} v
|
|
275
|
+
*/
|
|
276
|
+
writeUnsignedLong(v: bigint): void;
|
|
277
|
+
/**
|
|
278
|
+
* Returns a 64 bit (8 bytes) unsigned little-endian number.
|
|
279
|
+
* @returns {bigint}
|
|
280
|
+
*/
|
|
281
|
+
readUnsignedLongLE(): bigint;
|
|
282
|
+
/**
|
|
283
|
+
* Writes a 64 bit (8 bytes) unsigned little-endian number.
|
|
284
|
+
* @param {bigint} v
|
|
285
|
+
*/
|
|
286
|
+
writeUnsignedLongLE(v: bigint): void;
|
|
287
|
+
/**
|
|
288
|
+
* Reads a 32 bit (4 bytes) zigzag-encoded number.
|
|
289
|
+
* @returns {number}
|
|
290
|
+
*/
|
|
291
|
+
readVarInt(): number;
|
|
292
|
+
/**
|
|
293
|
+
* Writes a 32 bit (4 bytes) zigzag-encoded number.
|
|
294
|
+
* @param {number} v
|
|
295
|
+
*/
|
|
296
|
+
writeVarInt(v: number): void;
|
|
297
|
+
/**
|
|
298
|
+
* Reads a 32 bit unsigned number.
|
|
299
|
+
* @returns {number}
|
|
300
|
+
*/
|
|
301
|
+
readUnsignedVarInt(): number;
|
|
302
|
+
/**
|
|
303
|
+
* Writes a 32 bit unsigned number with variable-length.
|
|
304
|
+
* @param {number} v
|
|
305
|
+
*/
|
|
306
|
+
writeUnsignedVarInt(v: number): void;
|
|
307
|
+
/**
|
|
308
|
+
* Reads a 64 bit zigzag-encoded variable-length number.
|
|
309
|
+
* @returns {bigint}
|
|
310
|
+
*/
|
|
311
|
+
readVarLong(): bigint;
|
|
312
|
+
/**
|
|
313
|
+
* Writes a 64 bit unsigned zigzag-encoded number.
|
|
314
|
+
* @param {bigint} v
|
|
315
|
+
*/
|
|
316
|
+
writeVarLong(v: bigint): void;
|
|
317
|
+
/**
|
|
318
|
+
* Reads a 64 bit unsigned variable-length number.
|
|
319
|
+
* @returns {bigint}
|
|
320
|
+
*/
|
|
321
|
+
readUnsignedVarLong(): bigint;
|
|
322
|
+
/**
|
|
323
|
+
* Writes a 64 bit unsigned variable-length number.
|
|
324
|
+
* @param {bigint} v
|
|
325
|
+
*/
|
|
326
|
+
writeUnsignedVarLong(v: bigint): void;
|
|
327
|
+
/**
|
|
328
|
+
* Ensures write buffer has enough capacity, grows if needed.
|
|
329
|
+
* @param {number} needed
|
|
330
|
+
*/
|
|
331
|
+
private ensureCapacity;
|
|
332
|
+
/**
|
|
333
|
+
* Grows the write buffer so that at least `capacity` bytes can be written without any
|
|
334
|
+
* further allocation, and returns this stream.
|
|
335
|
+
*
|
|
336
|
+
* Pre-sizing skips the 256 -> 512 -> 1024 ... growth ladder, each step of which copies the
|
|
337
|
+
* whole payload; a 3 KB packet starting from the 256-byte floor performs five allocations
|
|
338
|
+
* and memcpy's 1.25x its own size before it is done.
|
|
339
|
+
* @param {number} capacity
|
|
340
|
+
*/
|
|
341
|
+
reserve(capacity: number): this;
|
|
342
|
+
/**
|
|
343
|
+
* Rewinds the write cursor while keeping the allocated capacity, so a long-lived encoder
|
|
344
|
+
* reaches a steady state where it never allocates again. This is the intended way to reuse
|
|
345
|
+
* a stream for many packets.
|
|
346
|
+
*
|
|
347
|
+
* Note the aliasing contract, which it shares with {@link clear} and {@link reuse}: any
|
|
348
|
+
* buffer previously handed out by {@link getWriteBuffer} is a *view* over this stream's
|
|
349
|
+
* memory and is invalidated by this call. Use {@link copyOut} or {@link copyInto} for
|
|
350
|
+
* output you intend to keep.
|
|
351
|
+
*/
|
|
352
|
+
resetWrite(): void;
|
|
353
|
+
/**
|
|
354
|
+
* Returns the encoded bytes as an exactly-sized, standalone Buffer.
|
|
355
|
+
*
|
|
356
|
+
* Unlike {@link getWriteBuffer} the result does not alias this stream, so it survives
|
|
357
|
+
* {@link resetWrite}, and it does not pin a pool chunk: because `Buffer.allocUnsafe` is
|
|
358
|
+
* pool-backed (`Buffer.poolSize` is 64 KB on current Node), holding on to a handful of
|
|
359
|
+
* small slices from {@link getWriteBuffer} can keep megabytes alive.
|
|
360
|
+
* @returns {Buffer}
|
|
361
|
+
*/
|
|
362
|
+
copyOut(): Buffer;
|
|
363
|
+
/**
|
|
364
|
+
* Copies the encoded bytes into a caller-owned buffer at `offset` and returns the offset
|
|
365
|
+
* just past them. Lets many packets be encoded into one arena with no per-packet
|
|
366
|
+
* allocation at all.
|
|
367
|
+
* @param {Buffer} target
|
|
368
|
+
* @param {number} offset
|
|
369
|
+
* @returns {number} the new offset
|
|
370
|
+
*/
|
|
371
|
+
copyInto(target: Buffer, offset?: number): number;
|
|
372
|
+
/**
|
|
373
|
+
* Increases the write offset by the given length.
|
|
374
|
+
* @param {number} length
|
|
375
|
+
*/
|
|
376
|
+
private addOffset;
|
|
377
|
+
/**
|
|
378
|
+
* Returns whatever or not the read offset is at end of line.
|
|
379
|
+
* @returns {number}
|
|
380
|
+
*/
|
|
381
|
+
feof(): boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Reads the remaining bytes and returns the buffer slice.
|
|
384
|
+
* @returns {Buffer}
|
|
385
|
+
*/
|
|
386
|
+
readRemaining(): Buffer;
|
|
387
|
+
/**
|
|
388
|
+
* Skips len bytes on the buffer.
|
|
389
|
+
* @param {number} len
|
|
390
|
+
*/
|
|
391
|
+
skip(len: number): void;
|
|
392
|
+
/**
|
|
393
|
+
* Returns the encoded buffer.
|
|
394
|
+
*
|
|
395
|
+
* Beware: when a read buffer is present this returns *that*, discarding everything
|
|
396
|
+
* written. On a stream used for both reading and writing it never returns your output.
|
|
397
|
+
* @returns {Buffer}
|
|
398
|
+
* @deprecated See {@link getReadBuffer} and {@link getWriteBuffer}.
|
|
399
|
+
*/
|
|
400
|
+
getBuffer(): Buffer;
|
|
401
|
+
/**
|
|
402
|
+
* Returns the read buffer if available.
|
|
403
|
+
* @returns {Buffer}
|
|
404
|
+
*/
|
|
405
|
+
getReadBuffer(): Buffer | null;
|
|
406
|
+
/**
|
|
407
|
+
* Returns the encoded bytes as a *view* over this stream's internal buffer.
|
|
408
|
+
*
|
|
409
|
+
* The view is only valid until the next write: {@link resetWrite}, {@link clear} and
|
|
410
|
+
* {@link reuse} all rewind the cursor without reallocating, so a previously returned
|
|
411
|
+
* buffer is silently overwritten by the next packet. If you queue the result - a send
|
|
412
|
+
* queue, a resend window - use {@link copyOut} or {@link copyInto} instead.
|
|
413
|
+
*
|
|
414
|
+
* It also keeps the whole pooled 64 KB chunk it was carved from alive; retaining a
|
|
415
|
+
* scattered handful of small packets this way can pin megabytes.
|
|
416
|
+
* @returns {Buffer}
|
|
417
|
+
*/
|
|
418
|
+
getWriteBuffer(): Buffer;
|
|
419
|
+
/**
|
|
420
|
+
* Sets the buffer for reading.
|
|
421
|
+
* make sure to reset the reading index!
|
|
422
|
+
* @param buf - The new Buffer.
|
|
423
|
+
* @deprecated See {@link setReadBuffer} and {@link setWriteBuffer}.
|
|
424
|
+
*/
|
|
425
|
+
setBuffer(buf: Buffer): void;
|
|
426
|
+
/**
|
|
427
|
+
* Sets the buffer for reading.
|
|
428
|
+
* @param buf - The new Buffer.
|
|
429
|
+
* @param rIndex - The new read index (default: 0, pass -1 to keep current).
|
|
430
|
+
*/
|
|
431
|
+
setReadBuffer(buf: Buffer, rIndex?: number): void;
|
|
432
|
+
/**
|
|
433
|
+
* Sets the buffer for writing.
|
|
434
|
+
* @param buf - The new Buffer.
|
|
435
|
+
* @param wIndex - The new write index (default: 0, pass -1 to keep current).
|
|
436
|
+
*/
|
|
437
|
+
setWriteBuffer(buf: Buffer, wIndex?: number): void;
|
|
438
|
+
/**
|
|
439
|
+
* Clears the whole BinaryStream instance.
|
|
440
|
+
*
|
|
441
|
+
* The write buffer and its capacity are kept, so any view previously returned by
|
|
442
|
+
* {@link getWriteBuffer} is invalidated. See {@link resetWrite}.
|
|
443
|
+
*/
|
|
444
|
+
clear(): void;
|
|
445
|
+
/**
|
|
446
|
+
* Conventional method to reuse the stream
|
|
447
|
+
* without having to create a new BinaryStream instance.
|
|
448
|
+
*
|
|
449
|
+
* The write buffer and its capacity are kept, so any view previously returned by
|
|
450
|
+
* {@link getWriteBuffer} is invalidated. See {@link resetWrite}.
|
|
451
|
+
* @param buf - The new buffer instance.
|
|
452
|
+
*/
|
|
453
|
+
reuse(buf: Buffer): void;
|
|
454
|
+
/**
|
|
455
|
+
* Sets the reading index.
|
|
456
|
+
* @param index - The new read index.
|
|
457
|
+
*/
|
|
458
|
+
setReadIndex(index: number): void;
|
|
459
|
+
/**
|
|
460
|
+
* Sets the new writing index.
|
|
461
|
+
* @param index - The new write index.
|
|
462
|
+
*/
|
|
463
|
+
setWriteIndex(index: number): void;
|
|
464
|
+
/**
|
|
465
|
+
* Retuns the read index.
|
|
466
|
+
* @returns {number}
|
|
467
|
+
*/
|
|
468
|
+
getReadIndex(): number;
|
|
469
|
+
/**
|
|
470
|
+
* Returns the write index.
|
|
471
|
+
* @returns {number}
|
|
472
|
+
*/
|
|
473
|
+
getWriteIndex(): number;
|
|
474
|
+
/**
|
|
475
|
+
* Do read assertions, check if the read buffer is null.
|
|
476
|
+
* @param {number} byteLength
|
|
477
|
+
*/
|
|
478
|
+
private doReadAssertions;
|
|
479
|
+
/**
|
|
480
|
+
* Do read assertions, check if the read buffer is null.
|
|
481
|
+
* @param {number|bigint} num
|
|
482
|
+
* @param {number|bigint} minVal
|
|
483
|
+
* @param {number|bigint} maxVal
|
|
484
|
+
*/
|
|
485
|
+
private doWriteAssertions;
|
|
486
|
+
}
|
|
487
|
+
export default BinaryStream;
|
|
488
|
+
//# sourceMappingURL=BinaryStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryStream.d.ts","sourceRoot":"","sources":["../src/BinaryStream.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAA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