@sapphire/string-store 2.0.0-next.8a922c42 → 2.0.1-next.014a7928

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 CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # [@sapphire/string-store@2.0.0](https://github.com/sapphiredev/utilities/compare/@sapphire/string-store@1.2.0...@sapphire/string-store@2.0.0) - (2025-01-31)
6
+
7
+ ## 🏠 Refactor
8
+
9
+ - Add `DuplexBuffer` interface ([548200f](https://github.com/sapphiredev/utilities/commit/548200f1af067ae2f017c27a3c5d056ec6dd7ff8)) ([#865](https://github.com/sapphiredev/utilities/pull/865) by @kyranet)
10
+ - **SchemaStore:** Introduce `serializeRaw` ([5141559](https://github.com/sapphiredev/utilities/commit/51415597fa4b8ed0e17ba71743e73f3963a6803b)) ([#862](https://github.com/sapphiredev/utilities/pull/862) by @kyranet)
11
+ - 💥 **BREAKING CHANGE:** `serialize` no longer returns an `UnalignedUint16Array`, if you desire the old behaviour, use `serializeRaw`
12
+
13
+ ## 🚀 Features
14
+
15
+ - **Schema:** Add serialization helpers ([8a922c4](https://github.com/sapphiredev/utilities/commit/8a922c421576707dcd1e74379544f20a8c43d785)) ([#864](https://github.com/sapphiredev/utilities/pull/864) by @kyranet)
16
+ - 💥 **BREAKING CHANGE:** `serialize` has been renamed to `serializeInto`
17
+
5
18
  # [@sapphire/string-store@1.2.0](https://github.com/sapphiredev/utilities/compare/@sapphire/string-store@1.1.0...@sapphire/string-store@1.2.0) - (2024-12-18)
6
19
 
7
20
  ## 🏠 Refactor
@@ -73,6 +73,247 @@ _value = new WeakMap();
73
73
  __name(_Pointer, "Pointer");
74
74
  var Pointer = _Pointer;
75
75
 
76
+ // src/lib/buffer/UnalignedUint16Array.ts
77
+ var ConverterUint8 = new Uint8Array(8);
78
+ var ConverterUint16 = new Uint16Array(ConverterUint8.buffer);
79
+ var ConverterUint32 = new Uint32Array(ConverterUint8.buffer);
80
+ var ConverterUint64 = new BigUint64Array(ConverterUint8.buffer);
81
+ var ConverterInt32 = new Int32Array(ConverterUint8.buffer);
82
+ var ConverterInt64 = new BigInt64Array(ConverterUint8.buffer);
83
+ var ConverterFloat = new Float32Array(ConverterUint8.buffer);
84
+ var ConverterDouble = new Float64Array(ConverterUint8.buffer);
85
+ var _buffer, _bitLength, _wordIndex, _wordLength, _UnalignedUint16Array_instances, readBit_fn, readByte_fn, bufferRead16_fn, bufferRead32_fn, bufferRead64_fn, writeBit_fn, bufferWrite16_fn;
86
+ var _UnalignedUint16Array = class _UnalignedUint16Array {
87
+ constructor(maxLength) {
88
+ __privateAdd(this, _UnalignedUint16Array_instances);
89
+ __privateAdd(this, _buffer);
90
+ __privateAdd(this, _bitLength, 0);
91
+ __privateAdd(this, _wordIndex, 0);
92
+ __privateAdd(this, _wordLength, 0);
93
+ __privateSet(this, _buffer, new Uint16Array(maxLength));
94
+ }
95
+ at(index) {
96
+ return __privateGet(this, _buffer).at(index);
97
+ }
98
+ get maxLength() {
99
+ return __privateGet(this, _buffer).length;
100
+ }
101
+ get maxBitLength() {
102
+ return __privateGet(this, _buffer).length * 16;
103
+ }
104
+ get length() {
105
+ return __privateGet(this, _wordLength);
106
+ }
107
+ get bitLength() {
108
+ return __privateGet(this, _bitLength);
109
+ }
110
+ writeBit(value) {
111
+ __privateMethod(this, _UnalignedUint16Array_instances, writeBit_fn).call(this, value);
112
+ }
113
+ writeInt2(value) {
114
+ this.writeBit(value & 1);
115
+ this.writeBit(value >> 1);
116
+ }
117
+ writeInt4(value) {
118
+ this.writeInt2(value & 3);
119
+ this.writeInt2(value >> 2);
120
+ }
121
+ writeInt8(value) {
122
+ this.writeInt4(value & 15);
123
+ this.writeInt4(value >> 4);
124
+ }
125
+ writeInt16(value) {
126
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
127
+ }
128
+ writeInt32(value) {
129
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
130
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value >> 16);
131
+ }
132
+ writeInt64(value) {
133
+ this.writeBigInt64(BigInt(value));
134
+ }
135
+ writeBigInt32(value) {
136
+ ConverterInt64[0] = value;
137
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
138
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
139
+ }
140
+ writeBigInt64(value) {
141
+ ConverterInt64[0] = value;
142
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
143
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
144
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
145
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
146
+ }
147
+ writeFloat32(value) {
148
+ ConverterFloat[0] = value;
149
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
150
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
151
+ }
152
+ writeFloat64(value) {
153
+ ConverterDouble[0] = value;
154
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
155
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
156
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
157
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
158
+ }
159
+ readBit(offset) {
160
+ const ptr = Pointer.from(offset);
161
+ return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
162
+ }
163
+ readInt2(offset) {
164
+ return this.readUint2(offset) << 30 >> 30;
165
+ }
166
+ readUint2(offset) {
167
+ const ptr = Pointer.from(offset);
168
+ return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
169
+ }
170
+ readInt4(offset) {
171
+ return this.readUint4(offset) << 28 >> 28;
172
+ }
173
+ readUint4(offset) {
174
+ const ptr = Pointer.from(offset);
175
+ return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3;
176
+ }
177
+ readInt8(offset) {
178
+ return this.readUint8(offset) << 24 >> 24;
179
+ }
180
+ readUint8(offset) {
181
+ const ptr = Pointer.from(offset);
182
+ return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
183
+ }
184
+ readInt16(offset) {
185
+ return this.readUint16(offset) << 16 >> 16;
186
+ }
187
+ readUint16(offset) {
188
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead16_fn).call(this, Pointer.from(offset));
189
+ return ConverterUint16[0];
190
+ }
191
+ readInt32(offset) {
192
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
193
+ return ConverterInt32[0];
194
+ }
195
+ readUint32(offset) {
196
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
197
+ return ConverterUint32[0];
198
+ }
199
+ readInt64(offset) {
200
+ return Number(this.readBigInt64(offset));
201
+ }
202
+ readUint64(offset) {
203
+ return Number(this.readBigUint64(offset));
204
+ }
205
+ readBigInt32(offset) {
206
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
207
+ return BigInt(ConverterInt32[0]);
208
+ }
209
+ readBigUint32(offset) {
210
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
211
+ return BigInt(ConverterUint32[0]);
212
+ }
213
+ readBigInt64(offset) {
214
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
215
+ return ConverterInt64[0];
216
+ }
217
+ readBigUint64(offset) {
218
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
219
+ return ConverterUint64[0];
220
+ }
221
+ readFloat32(offset) {
222
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
223
+ return ConverterFloat[0];
224
+ }
225
+ readFloat64(offset) {
226
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
227
+ return ConverterDouble[0];
228
+ }
229
+ toString() {
230
+ let result = "";
231
+ for (let i = 0; i < this.length; i++) {
232
+ result += String.fromCharCode(__privateGet(this, _buffer)[i]);
233
+ }
234
+ return result;
235
+ }
236
+ toArray() {
237
+ return __privateGet(this, _buffer).slice(0, this.length);
238
+ }
239
+ static from(value) {
240
+ if (typeof value !== "string") return value;
241
+ const buffer = new _UnalignedUint16Array(value.length);
242
+ for (let i = 0; i < value.length; i++) {
243
+ __privateGet(buffer, _buffer)[i] = value.charCodeAt(i);
244
+ }
245
+ __privateSet(buffer, _bitLength, value.length << 4);
246
+ return buffer;
247
+ }
248
+ };
249
+ _buffer = new WeakMap();
250
+ _bitLength = new WeakMap();
251
+ _wordIndex = new WeakMap();
252
+ _wordLength = new WeakMap();
253
+ _UnalignedUint16Array_instances = new WeakSet();
254
+ readBit_fn = /* @__PURE__ */ __name(function(pointer) {
255
+ const bitOffset = pointer.value;
256
+ const index = bitOffset >> 4;
257
+ const bitIndex = bitOffset & 15;
258
+ pointer.add(1);
259
+ return __privateGet(this, _buffer)[index] >> bitIndex & 1;
260
+ }, "#readBit");
261
+ readByte_fn = /* @__PURE__ */ __name(function(ptr) {
262
+ return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 4 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 5 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 6 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 7;
263
+ }, "#readByte");
264
+ bufferRead16_fn = /* @__PURE__ */ __name(function(ptr) {
265
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
266
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
267
+ }, "#bufferRead16");
268
+ bufferRead32_fn = /* @__PURE__ */ __name(function(ptr) {
269
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
270
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
271
+ ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
272
+ ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
273
+ }, "#bufferRead32");
274
+ bufferRead64_fn = /* @__PURE__ */ __name(function(ptr) {
275
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
276
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
277
+ ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
278
+ ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
279
+ ConverterUint8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
280
+ ConverterUint8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
281
+ ConverterUint8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
282
+ ConverterUint8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
283
+ }, "#bufferRead64");
284
+ writeBit_fn = /* @__PURE__ */ __name(function(value) {
285
+ if (__privateGet(this, _wordIndex) === this.maxLength) {
286
+ throw new RangeError(`The buffer is full`);
287
+ }
288
+ if (value) {
289
+ const index = __privateGet(this, _wordIndex);
290
+ const bitIndex = this.bitLength & 15;
291
+ __privateGet(this, _buffer)[index] |= 1 << bitIndex;
292
+ }
293
+ if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordLength)._++;
294
+ __privateWrapper(this, _bitLength)._++;
295
+ if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordIndex)._++;
296
+ }, "#writeBit");
297
+ bufferWrite16_fn = /* @__PURE__ */ __name(function(value) {
298
+ const wordIndex = __privateGet(this, _wordIndex);
299
+ const bitIndex = this.bitLength & 15;
300
+ if (wordIndex + (bitIndex === 0 ? 0 : 1) === this.maxLength) {
301
+ throw new RangeError(`The buffer is full`);
302
+ }
303
+ if (bitIndex === 0) {
304
+ __privateGet(this, _buffer)[wordIndex] = value;
305
+ } else {
306
+ value &= 65535;
307
+ __privateGet(this, _buffer)[wordIndex] |= value << bitIndex;
308
+ __privateGet(this, _buffer)[wordIndex + 1] = value >> 16 - bitIndex;
309
+ }
310
+ __privateSet(this, _bitLength, __privateGet(this, _bitLength) + 16);
311
+ __privateWrapper(this, _wordIndex)._++;
312
+ __privateWrapper(this, _wordLength)._++;
313
+ }, "#bufferWrite16");
314
+ __name(_UnalignedUint16Array, "UnalignedUint16Array");
315
+ var UnalignedUint16Array = _UnalignedUint16Array;
316
+
76
317
  // src/lib/types/Array.ts
77
318
  function ArrayType(type) {
78
319
  return {
@@ -436,247 +677,6 @@ var t = {
436
677
  uint8: Uint8Type
437
678
  };
438
679
 
439
- // src/lib/UnalignedUint16Array.ts
440
- var ConverterUint8 = new Uint8Array(8);
441
- var ConverterUint16 = new Uint16Array(ConverterUint8.buffer);
442
- var ConverterUint32 = new Uint32Array(ConverterUint8.buffer);
443
- var ConverterUint64 = new BigUint64Array(ConverterUint8.buffer);
444
- var ConverterInt32 = new Int32Array(ConverterUint8.buffer);
445
- var ConverterInt64 = new BigInt64Array(ConverterUint8.buffer);
446
- var ConverterFloat = new Float32Array(ConverterUint8.buffer);
447
- var ConverterDouble = new Float64Array(ConverterUint8.buffer);
448
- var _buffer, _bitLength, _wordIndex, _wordLength, _UnalignedUint16Array_instances, readBit_fn, readByte_fn, bufferRead16_fn, bufferRead32_fn, bufferRead64_fn, writeBit_fn, bufferWrite16_fn;
449
- var _UnalignedUint16Array = class _UnalignedUint16Array {
450
- constructor(maxLength) {
451
- __privateAdd(this, _UnalignedUint16Array_instances);
452
- __privateAdd(this, _buffer);
453
- __privateAdd(this, _bitLength, 0);
454
- __privateAdd(this, _wordIndex, 0);
455
- __privateAdd(this, _wordLength, 0);
456
- __privateSet(this, _buffer, new Uint16Array(maxLength));
457
- }
458
- at(index) {
459
- return __privateGet(this, _buffer).at(index);
460
- }
461
- get maxLength() {
462
- return __privateGet(this, _buffer).length;
463
- }
464
- get maxBitLength() {
465
- return __privateGet(this, _buffer).length * 16;
466
- }
467
- get length() {
468
- return __privateGet(this, _wordLength);
469
- }
470
- get bitLength() {
471
- return __privateGet(this, _bitLength);
472
- }
473
- writeBit(value) {
474
- __privateMethod(this, _UnalignedUint16Array_instances, writeBit_fn).call(this, value);
475
- }
476
- writeInt2(value) {
477
- this.writeBit(value & 1);
478
- this.writeBit(value >> 1);
479
- }
480
- writeInt4(value) {
481
- this.writeInt2(value & 3);
482
- this.writeInt2(value >> 2);
483
- }
484
- writeInt8(value) {
485
- this.writeInt4(value & 15);
486
- this.writeInt4(value >> 4);
487
- }
488
- writeInt16(value) {
489
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
490
- }
491
- writeInt32(value) {
492
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
493
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value >> 16);
494
- }
495
- writeInt64(value) {
496
- this.writeBigInt64(BigInt(value));
497
- }
498
- writeBigInt32(value) {
499
- ConverterInt64[0] = value;
500
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
501
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
502
- }
503
- writeBigInt64(value) {
504
- ConverterInt64[0] = value;
505
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
506
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
507
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
508
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
509
- }
510
- writeFloat32(value) {
511
- ConverterFloat[0] = value;
512
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
513
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
514
- }
515
- writeFloat64(value) {
516
- ConverterDouble[0] = value;
517
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
518
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
519
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
520
- __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
521
- }
522
- readBit(offset) {
523
- const ptr = Pointer.from(offset);
524
- return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
525
- }
526
- readInt2(offset) {
527
- return this.readUint2(offset) << 30 >> 30;
528
- }
529
- readUint2(offset) {
530
- const ptr = Pointer.from(offset);
531
- return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
532
- }
533
- readInt4(offset) {
534
- return this.readUint4(offset) << 28 >> 28;
535
- }
536
- readUint4(offset) {
537
- const ptr = Pointer.from(offset);
538
- return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3;
539
- }
540
- readInt8(offset) {
541
- return this.readUint8(offset) << 24 >> 24;
542
- }
543
- readUint8(offset) {
544
- const ptr = Pointer.from(offset);
545
- return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
546
- }
547
- readInt16(offset) {
548
- return this.readUint16(offset) << 16 >> 16;
549
- }
550
- readUint16(offset) {
551
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead16_fn).call(this, Pointer.from(offset));
552
- return ConverterUint16[0];
553
- }
554
- readInt32(offset) {
555
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
556
- return ConverterInt32[0];
557
- }
558
- readUint32(offset) {
559
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
560
- return ConverterUint32[0];
561
- }
562
- readInt64(offset) {
563
- return Number(this.readBigInt64(offset));
564
- }
565
- readUint64(offset) {
566
- return Number(this.readBigUint64(offset));
567
- }
568
- readBigInt32(offset) {
569
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
570
- return BigInt(ConverterInt32[0]);
571
- }
572
- readBigUint32(offset) {
573
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
574
- return BigInt(ConverterUint32[0]);
575
- }
576
- readBigInt64(offset) {
577
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
578
- return ConverterInt64[0];
579
- }
580
- readBigUint64(offset) {
581
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
582
- return ConverterUint64[0];
583
- }
584
- readFloat32(offset) {
585
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
586
- return ConverterFloat[0];
587
- }
588
- readFloat64(offset) {
589
- __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
590
- return ConverterDouble[0];
591
- }
592
- toString() {
593
- let result = "";
594
- for (let i = 0; i < this.length; i++) {
595
- result += String.fromCharCode(__privateGet(this, _buffer)[i]);
596
- }
597
- return result;
598
- }
599
- toArray() {
600
- return __privateGet(this, _buffer).slice(0, this.length);
601
- }
602
- static from(value) {
603
- if (value instanceof _UnalignedUint16Array) return value;
604
- const buffer = new _UnalignedUint16Array(value.length);
605
- for (let i = 0; i < value.length; i++) {
606
- __privateGet(buffer, _buffer)[i] = value.charCodeAt(i);
607
- }
608
- __privateSet(buffer, _bitLength, value.length << 4);
609
- return buffer;
610
- }
611
- };
612
- _buffer = new WeakMap();
613
- _bitLength = new WeakMap();
614
- _wordIndex = new WeakMap();
615
- _wordLength = new WeakMap();
616
- _UnalignedUint16Array_instances = new WeakSet();
617
- readBit_fn = /* @__PURE__ */ __name(function(pointer) {
618
- const bitOffset = pointer.value;
619
- const index = bitOffset >> 4;
620
- const bitIndex = bitOffset & 15;
621
- pointer.add(1);
622
- return __privateGet(this, _buffer)[index] >> bitIndex & 1;
623
- }, "#readBit");
624
- readByte_fn = /* @__PURE__ */ __name(function(ptr) {
625
- return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 4 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 5 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 6 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 7;
626
- }, "#readByte");
627
- bufferRead16_fn = /* @__PURE__ */ __name(function(ptr) {
628
- ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
629
- ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
630
- }, "#bufferRead16");
631
- bufferRead32_fn = /* @__PURE__ */ __name(function(ptr) {
632
- ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
633
- ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
634
- ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
635
- ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
636
- }, "#bufferRead32");
637
- bufferRead64_fn = /* @__PURE__ */ __name(function(ptr) {
638
- ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
639
- ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
640
- ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
641
- ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
642
- ConverterUint8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
643
- ConverterUint8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
644
- ConverterUint8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
645
- ConverterUint8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
646
- }, "#bufferRead64");
647
- writeBit_fn = /* @__PURE__ */ __name(function(value) {
648
- if (__privateGet(this, _wordIndex) === this.maxLength) {
649
- throw new RangeError(`The buffer is full`);
650
- }
651
- if (value) {
652
- const index = __privateGet(this, _wordIndex);
653
- const bitIndex = this.bitLength & 15;
654
- __privateGet(this, _buffer)[index] |= 1 << bitIndex;
655
- }
656
- if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordLength)._++;
657
- __privateWrapper(this, _bitLength)._++;
658
- if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordIndex)._++;
659
- }, "#writeBit");
660
- bufferWrite16_fn = /* @__PURE__ */ __name(function(value) {
661
- const wordIndex = __privateGet(this, _wordIndex);
662
- const bitIndex = this.bitLength & 15;
663
- if (wordIndex + (bitIndex === 0 ? 0 : 1) === this.maxLength) {
664
- throw new RangeError(`The buffer is full`);
665
- }
666
- if (bitIndex === 0) {
667
- __privateGet(this, _buffer)[wordIndex] = value;
668
- } else {
669
- value &= 65535;
670
- __privateGet(this, _buffer)[wordIndex] |= value << bitIndex;
671
- __privateGet(this, _buffer)[wordIndex + 1] = value >> 16 - bitIndex;
672
- }
673
- __privateSet(this, _bitLength, __privateGet(this, _bitLength) + 16);
674
- __privateWrapper(this, _wordIndex)._++;
675
- __privateWrapper(this, _wordLength)._++;
676
- }, "#bufferWrite16");
677
- __name(_UnalignedUint16Array, "UnalignedUint16Array");
678
- var UnalignedUint16Array = _UnalignedUint16Array;
679
-
680
680
  // src/lib/schema/Schema.ts
681
681
  var _id, _types, _bitSize, _Schema_instances, addType_fn;
682
682
  var _Schema = class _Schema {