@sapphire/string-store 1.0.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.
@@ -0,0 +1,1243 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __typeError = (msg) => {
5
+ throw TypeError(msg);
6
+ };
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
10
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
11
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
12
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
14
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
15
+ var __privateWrapper = (obj, member, setter, getter) => ({
16
+ set _(value) {
17
+ __privateSet(obj, member, value);
18
+ },
19
+ get _() {
20
+ return __privateGet(obj, member, getter);
21
+ }
22
+ });
23
+
24
+ // src/lib/shared/_common.ts
25
+ function isArrayLike(object) {
26
+ if (!isObject(object)) return false;
27
+ if (Array.isArray(object)) return true;
28
+ if (!hasLength(object)) return false;
29
+ if (!isValidLength(object.length)) return false;
30
+ return object.length === 0 || object.length - 1 in object;
31
+ }
32
+ __name(isArrayLike, "isArrayLike");
33
+ function isObject(item) {
34
+ return typeof item === "object" && item !== null;
35
+ }
36
+ __name(isObject, "isObject");
37
+ function hasLength(item) {
38
+ return "length" in item && typeof item.length === "number";
39
+ }
40
+ __name(hasLength, "hasLength");
41
+ function isValidLength(length) {
42
+ return Number.isSafeInteger(length) && length >= 0 && length < 2147483648;
43
+ }
44
+ __name(isValidLength, "isValidLength");
45
+
46
+ // src/lib/shared/Pointer.ts
47
+ var _value;
48
+ var _Pointer = class _Pointer {
49
+ constructor() {
50
+ __privateAdd(this, _value, 0);
51
+ }
52
+ get value() {
53
+ return __privateGet(this, _value);
54
+ }
55
+ add(value) {
56
+ const added = __privateGet(this, _value) + value;
57
+ if (!isValidLength(added)) {
58
+ throw new RangeError(`The pointer value cannot be an invalid length value`);
59
+ }
60
+ __privateSet(this, _value, added);
61
+ return this;
62
+ }
63
+ static from(pointer) {
64
+ if (pointer instanceof _Pointer) {
65
+ return pointer;
66
+ }
67
+ const instance = new _Pointer();
68
+ instance.add(Number(pointer));
69
+ return instance;
70
+ }
71
+ };
72
+ _value = new WeakMap();
73
+ __name(_Pointer, "Pointer");
74
+ var Pointer = _Pointer;
75
+
76
+ // src/lib/types/Array.ts
77
+ function ArrayType(type) {
78
+ return {
79
+ serialize(buffer, values) {
80
+ if (!isArrayLike(values)) {
81
+ throw new TypeError(`Expected an array, got ${values}`);
82
+ }
83
+ buffer.writeInt16(values.length);
84
+ for (const value of values) {
85
+ type.serialize(buffer, value);
86
+ }
87
+ },
88
+ deserialize(buffer, pointer) {
89
+ const length = buffer.readUint16(pointer);
90
+ const value = [];
91
+ for (let i = 0; i < length; i++) {
92
+ value.push(type.deserialize(buffer, pointer));
93
+ }
94
+ return value;
95
+ },
96
+ BIT_SIZE: null
97
+ };
98
+ }
99
+ __name(ArrayType, "ArrayType");
100
+
101
+ // src/lib/types/BigInt32.ts
102
+ var BigInt32Type = {
103
+ serialize(buffer, value) {
104
+ buffer.writeBigInt32(value);
105
+ },
106
+ deserialize(buffer, pointer) {
107
+ return buffer.readBigInt32(pointer);
108
+ },
109
+ BIT_SIZE: 32
110
+ };
111
+
112
+ // src/lib/types/BigInt64.ts
113
+ var BigInt64Type = {
114
+ serialize(buffer, value) {
115
+ buffer.writeBigInt64(value);
116
+ },
117
+ deserialize(buffer, pointer) {
118
+ return buffer.readBigInt64(pointer);
119
+ },
120
+ BIT_SIZE: 64
121
+ };
122
+
123
+ // src/lib/types/BigUint32.ts
124
+ var BigUint32Type = {
125
+ serialize(buffer, value) {
126
+ buffer.writeBigInt32(value);
127
+ },
128
+ deserialize(buffer, pointer) {
129
+ return buffer.readBigUint32(pointer);
130
+ },
131
+ BIT_SIZE: 32
132
+ };
133
+
134
+ // src/lib/types/BigUint64.ts
135
+ var BigUint64Type = {
136
+ serialize(buffer, value) {
137
+ buffer.writeBigInt64(value);
138
+ },
139
+ deserialize(buffer, pointer) {
140
+ return buffer.readBigUint64(pointer);
141
+ },
142
+ BIT_SIZE: 64
143
+ };
144
+
145
+ // src/lib/types/Bit.ts
146
+ var BitType = {
147
+ serialize(buffer, value) {
148
+ buffer.writeBit(value & 1);
149
+ },
150
+ deserialize(buffer, pointer) {
151
+ return buffer.readBit(pointer);
152
+ },
153
+ BIT_SIZE: 1
154
+ };
155
+
156
+ // src/lib/types/Boolean.ts
157
+ var BooleanType = {
158
+ serialize(buffer, value) {
159
+ buffer.writeBit(Number(value));
160
+ },
161
+ deserialize(buffer, pointer) {
162
+ return buffer.readBit(pointer) === 1;
163
+ },
164
+ BIT_SIZE: 1
165
+ };
166
+
167
+ // src/lib/types/FixedLengthArray.ts
168
+ function FixedLengthArrayType(type, length) {
169
+ return {
170
+ serialize(buffer, values) {
171
+ if (!isArrayLike(values) || values.length !== length) {
172
+ throw new TypeError(`Expected array of length ${length}, got ${values.length}`);
173
+ }
174
+ for (let i = 0; i < length; i++) {
175
+ type.serialize(buffer, values[i]);
176
+ }
177
+ },
178
+ deserialize(buffer, pointer) {
179
+ const value = [];
180
+ for (let i = 0; i < length; i++) {
181
+ value.push(type.deserialize(buffer, pointer));
182
+ }
183
+ return value;
184
+ },
185
+ BIT_SIZE: typeof type.BIT_SIZE === "number" ? type.BIT_SIZE * length : null
186
+ };
187
+ }
188
+ __name(FixedLengthArrayType, "FixedLengthArrayType");
189
+
190
+ // src/lib/types/Float32.ts
191
+ var Float32Type = {
192
+ serialize(buffer, value) {
193
+ buffer.writeFloat32(value);
194
+ },
195
+ deserialize(buffer, pointer) {
196
+ return buffer.readFloat32(pointer);
197
+ },
198
+ BIT_SIZE: 32
199
+ };
200
+
201
+ // src/lib/types/Float64.ts
202
+ var Float64Type = {
203
+ serialize(buffer, value) {
204
+ buffer.writeFloat64(value);
205
+ },
206
+ deserialize(buffer, pointer) {
207
+ return buffer.readFloat64(pointer);
208
+ },
209
+ BIT_SIZE: 64
210
+ };
211
+
212
+ // src/lib/types/Int16.ts
213
+ var Int16Type = {
214
+ serialize(buffer, value) {
215
+ buffer.writeInt16(value);
216
+ },
217
+ deserialize(buffer, pointer) {
218
+ return buffer.readInt16(pointer);
219
+ },
220
+ BIT_SIZE: 16
221
+ };
222
+
223
+ // src/lib/types/Int2.ts
224
+ var Int2Type = {
225
+ serialize(buffer, value) {
226
+ buffer.writeInt2(value);
227
+ },
228
+ deserialize(buffer, pointer) {
229
+ return buffer.readInt2(pointer);
230
+ },
231
+ BIT_SIZE: 2
232
+ };
233
+
234
+ // src/lib/types/Int32.ts
235
+ var Int32Type = {
236
+ serialize(buffer, value) {
237
+ buffer.writeInt32(value);
238
+ },
239
+ deserialize(buffer, pointer) {
240
+ return buffer.readInt32(pointer);
241
+ },
242
+ BIT_SIZE: 32
243
+ };
244
+
245
+ // src/lib/types/Int4.ts
246
+ var Int4Type = {
247
+ serialize(buffer, value) {
248
+ buffer.writeInt4(value);
249
+ },
250
+ deserialize(buffer, pointer) {
251
+ return buffer.readInt4(pointer);
252
+ },
253
+ BIT_SIZE: 4
254
+ };
255
+
256
+ // src/lib/types/Int64.ts
257
+ var Int64Type = {
258
+ serialize(buffer, value) {
259
+ buffer.writeInt64(value);
260
+ },
261
+ deserialize(buffer, pointer) {
262
+ return buffer.readInt64(pointer);
263
+ },
264
+ BIT_SIZE: 64
265
+ };
266
+
267
+ // src/lib/types/Int8.ts
268
+ var Int8Type = {
269
+ serialize(buffer, value) {
270
+ buffer.writeInt8(value);
271
+ },
272
+ deserialize(buffer, pointer) {
273
+ return buffer.readInt8(pointer);
274
+ },
275
+ BIT_SIZE: 8
276
+ };
277
+
278
+ // src/lib/types/Snowflake.ts
279
+ var SnowflakeType = {
280
+ serialize(buffer, value) {
281
+ buffer.writeBigInt64(BigInt(value));
282
+ },
283
+ deserialize(buffer, offset) {
284
+ return buffer.readBigUint64(offset);
285
+ },
286
+ BIT_SIZE: 64
287
+ };
288
+
289
+ // src/lib/types/String.ts
290
+ var encoder = new TextEncoder();
291
+ var decoder = new TextDecoder();
292
+ var StringType = {
293
+ serialize(buffer, value) {
294
+ const encoded = encoder.encode(value);
295
+ buffer.writeInt16(encoded.length);
296
+ for (const byte of encoded) {
297
+ buffer.writeInt8(byte);
298
+ }
299
+ },
300
+ deserialize(buffer, pointer) {
301
+ const length = buffer.readInt16(pointer);
302
+ const bytes = new Uint8Array(length);
303
+ for (let i = 0; i < length; i++) {
304
+ bytes[i] = buffer.readInt8(pointer);
305
+ }
306
+ return decoder.decode(bytes);
307
+ },
308
+ BIT_SIZE: null
309
+ };
310
+
311
+ // src/lib/types/Uint16.ts
312
+ var Uint16Type = {
313
+ serialize(buffer, value) {
314
+ buffer.writeInt16(value);
315
+ },
316
+ deserialize(buffer, pointer) {
317
+ return buffer.readUint16(pointer);
318
+ },
319
+ BIT_SIZE: 16
320
+ };
321
+
322
+ // src/lib/types/Uint2.ts
323
+ var Uint2Type = {
324
+ serialize(buffer, value) {
325
+ buffer.writeInt2(value);
326
+ },
327
+ deserialize(buffer, pointer) {
328
+ return buffer.readUint2(pointer);
329
+ },
330
+ BIT_SIZE: 2
331
+ };
332
+
333
+ // src/lib/types/Uint32.ts
334
+ var Uint32Type = {
335
+ serialize(buffer, value) {
336
+ buffer.writeInt32(value);
337
+ },
338
+ deserialize(buffer, pointer) {
339
+ return buffer.readUint32(pointer);
340
+ },
341
+ BIT_SIZE: 32
342
+ };
343
+
344
+ // src/lib/types/Uint4.ts
345
+ var Uint4Type = {
346
+ serialize(buffer, value) {
347
+ buffer.writeInt4(value);
348
+ },
349
+ deserialize(buffer, pointer) {
350
+ return buffer.readUint4(pointer);
351
+ },
352
+ BIT_SIZE: 4
353
+ };
354
+
355
+ // src/lib/types/Uint64.ts
356
+ var Uint64Type = {
357
+ serialize(buffer, value) {
358
+ buffer.writeInt64(value);
359
+ },
360
+ deserialize(buffer, pointer) {
361
+ return buffer.readUint64(pointer);
362
+ },
363
+ BIT_SIZE: 64
364
+ };
365
+
366
+ // src/lib/types/Uint8.ts
367
+ var Uint8Type = {
368
+ serialize(buffer, value) {
369
+ buffer.writeInt8(value);
370
+ },
371
+ deserialize(buffer, pointer) {
372
+ return buffer.readUint8(pointer);
373
+ },
374
+ BIT_SIZE: 8
375
+ };
376
+
377
+ // src/lib/types/index.ts
378
+ var t = {
379
+ array: ArrayType,
380
+ bigInt32: BigInt32Type,
381
+ bigInt64: BigInt64Type,
382
+ bigUint32: BigUint32Type,
383
+ bigUint64: BigUint64Type,
384
+ bit: BitType,
385
+ boolean: BooleanType,
386
+ fixedLengthArray: FixedLengthArrayType,
387
+ float32: Float32Type,
388
+ float64: Float64Type,
389
+ int16: Int16Type,
390
+ int2: Int2Type,
391
+ int32: Int32Type,
392
+ int4: Int4Type,
393
+ int64: Int64Type,
394
+ int8: Int8Type,
395
+ snowflake: SnowflakeType,
396
+ string: StringType,
397
+ uint16: Uint16Type,
398
+ uint2: Uint2Type,
399
+ uint32: Uint32Type,
400
+ uint4: Uint4Type,
401
+ uint64: Uint64Type,
402
+ uint8: Uint8Type
403
+ };
404
+
405
+ // src/lib/schema/Schema.ts
406
+ var _id, _types, _bitSize, _Schema_instances, addType_fn;
407
+ var _Schema = class _Schema {
408
+ /**
409
+ * Creates a new schema.
410
+ *
411
+ * @param id The id of the schema
412
+ */
413
+ constructor(id) {
414
+ __privateAdd(this, _Schema_instances);
415
+ __privateAdd(this, _id);
416
+ __privateAdd(this, _types, /* @__PURE__ */ new Map());
417
+ __privateAdd(this, _bitSize, 0);
418
+ __privateSet(this, _id, id);
419
+ }
420
+ /**
421
+ * The id of the schema.
422
+ */
423
+ get id() {
424
+ return __privateGet(this, _id);
425
+ }
426
+ /**
427
+ * The total bit size of the schema.
428
+ *
429
+ * @remarks
430
+ *
431
+ * If any of the entries have a bit size of `null`, the bit size of the
432
+ * schema will also be `null`.
433
+ */
434
+ get bitSize() {
435
+ return __privateGet(this, _bitSize);
436
+ }
437
+ /**
438
+ * Get a property from the schema.
439
+ *
440
+ * @param name The name of the property
441
+ * @returns The specified property
442
+ *
443
+ * @remarks
444
+ *
445
+ * If the property does not exist, an error will be thrown.
446
+ */
447
+ get(name) {
448
+ const type = __privateGet(this, _types).get(name);
449
+ if (!type) throw new Error(`Schema with id ${__privateGet(this, _id)} does not have a property with name "${name}"`);
450
+ return type;
451
+ }
452
+ /**
453
+ * Serialize a value into a buffer.
454
+ *
455
+ * @param buffer The buffer to serialize
456
+ * @param value The value to serialize into the buffer
457
+ *
458
+ * @remarks
459
+ *
460
+ * The schema's ID is written to the buffer first, followed by each property
461
+ * in the schema.
462
+ */
463
+ serialize(buffer, value) {
464
+ buffer.writeInt16(__privateGet(this, _id));
465
+ for (const [name, type] of this) {
466
+ type.serialize(buffer, value[name]);
467
+ }
468
+ }
469
+ /**
470
+ * Deserialize a value from a buffer.
471
+ *
472
+ * @param buffer The buffer to deserialize
473
+ * @param pointer The pointer to where the buffer should be read from
474
+ * @returns The deserialized value
475
+ *
476
+ * @remarks
477
+ *
478
+ * Unlike {@link Schema.serialize}, this method does not read the schema's ID
479
+ * from the buffer, that is reserved for the {@link SchemaStore}.
480
+ */
481
+ deserialize(buffer, pointer) {
482
+ const ptr = Pointer.from(pointer);
483
+ const result = /* @__PURE__ */ Object.create(null);
484
+ for (const [name, type] of this) {
485
+ result[name] = type.deserialize(buffer, ptr);
486
+ }
487
+ return result;
488
+ }
489
+ /**
490
+ * Adds an array property to the schema.
491
+ *
492
+ * @seealso {@link Schema.fixedLengthArray} for a fixed length array
493
+ *
494
+ * @param name The name of the property
495
+ * @param type The type of the entry in the array
496
+ * @returns The modified schema
497
+ */
498
+ array(name, type) {
499
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.array(type));
500
+ }
501
+ /**
502
+ * Adds a fixed length array property to the schema.
503
+ *
504
+ * @seealso {@link Schema.array} for a dynamic length array
505
+ *
506
+ * @param name The name of the property
507
+ * @param type The type of the entry in the array
508
+ * @param length The length of the array
509
+ * @returns The modified schema
510
+ */
511
+ fixedLengthArray(name, type, length) {
512
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.fixedLengthArray(type, length));
513
+ }
514
+ /**
515
+ * Adds a string property to the schema.
516
+ *
517
+ * @param name The name of the property
518
+ * @returns The modified schema
519
+ */
520
+ string(name) {
521
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.string);
522
+ }
523
+ /**
524
+ * Adds a boolean property to the schema.
525
+ *
526
+ * @param name The name of the property
527
+ * @returns The modified schema
528
+ */
529
+ boolean(name) {
530
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.boolean);
531
+ }
532
+ /**
533
+ * Adds a bit property to the schema.
534
+ *
535
+ * @param name The name of the property
536
+ * @returns The modified schema
537
+ */
538
+ bit(name) {
539
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bit);
540
+ }
541
+ /**
542
+ * Adds a 2-bit integer property to the schema.
543
+ *
544
+ * @remarks
545
+ *
546
+ * The range of values is from -2 to 1, inclusive.
547
+ *
548
+ * @param name The name of the property
549
+ * @returns The modified schema
550
+ */
551
+ int2(name) {
552
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int2);
553
+ }
554
+ /**
555
+ * Adds a 2-bit unsigned integer property to the schema.
556
+ *
557
+ * @remarks
558
+ *
559
+ * The range of values is from 0 to 3, inclusive.
560
+ *
561
+ * @param name The name of the property
562
+ * @returns The modified schema
563
+ */
564
+ uint2(name) {
565
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint2);
566
+ }
567
+ /**
568
+ * Adds a 4-bit integer property to the schema.
569
+ *
570
+ * @remarks
571
+ *
572
+ * The range of values is from -8 to 7, inclusive.
573
+ *
574
+ * @param name The name of the property
575
+ * @returns The modified schema
576
+ */
577
+ int4(name) {
578
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int4);
579
+ }
580
+ /**
581
+ * Adds a 4-bit unsigned integer property to the schema.
582
+ *
583
+ * @remarks
584
+ *
585
+ * The range of values is from 0 to 15, inclusive.
586
+ *
587
+ * @param name The name of the property
588
+ * @returns The modified schema
589
+ */
590
+ uint4(name) {
591
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint4);
592
+ }
593
+ /**
594
+ * Adds a 8-bit integer property to the schema.
595
+ *
596
+ * @remarks
597
+ *
598
+ * The range of values is from -128 to 127, inclusive.
599
+ *
600
+ * @param name The name of the property
601
+ * @returns The modified schema
602
+ */
603
+ int8(name) {
604
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int8);
605
+ }
606
+ /**
607
+ * Adds a 8-bit unsigned integer property to the schema.
608
+ *
609
+ * @remarks
610
+ *
611
+ * The range of values is from 0 to 255, inclusive.
612
+ *
613
+ * @param name The name of the property
614
+ * @returns The modified schema
615
+ */
616
+ uint8(name) {
617
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint8);
618
+ }
619
+ /**
620
+ * Adds a 16-bit integer property to the schema.
621
+ *
622
+ * @remarks
623
+ *
624
+ * The range of values is from -32768 to 32767, inclusive.
625
+ *
626
+ * @param name The name of the property
627
+ * @returns The modified schema
628
+ */
629
+ int16(name) {
630
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int16);
631
+ }
632
+ /**
633
+ * Adds a 16-bit unsigned integer property to the schema.
634
+ *
635
+ * @remarks
636
+ *
637
+ * The range of values is from 0 to 65535, inclusive.
638
+ *
639
+ * @param name The name of the property
640
+ * @returns The modified schema
641
+ */
642
+ uint16(name) {
643
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint16);
644
+ }
645
+ /**
646
+ * Adds a 32-bit integer property to the schema.
647
+ *
648
+ * @remarks
649
+ *
650
+ * The range of values is from -2_147_483_648 to 2_147_483_647, inclusive.
651
+ *
652
+ * @param name The name of the property
653
+ * @returns The modified schema
654
+ */
655
+ int32(name) {
656
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int32);
657
+ }
658
+ /**
659
+ * Adds a 32-bit unsigned integer property to the schema.
660
+ *
661
+ * @remarks
662
+ *
663
+ * The range of values is from 0 to 4_294_967_295, inclusive.
664
+ *
665
+ * @param name The name of the property
666
+ * @returns The modified schema
667
+ */
668
+ uint32(name) {
669
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint32);
670
+ }
671
+ /**
672
+ * Adds a 64-bit integer property to the schema.
673
+ *
674
+ * @remarks
675
+ *
676
+ * The range of values is from -9_223_372_036_854_775_808 to 9_223_372_036_854_775_807, inclusive.
677
+ *
678
+ * However, it may run into precision issues past the range of `-9_007_199_254_740_991` to `9_007_199_254_740_991`
679
+ *
680
+ * @param name The name of the property
681
+ * @returns The modified schema
682
+ */
683
+ int64(name) {
684
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int64);
685
+ }
686
+ /**
687
+ * Adds a 64-bit unsigned integer property to the schema.
688
+ *
689
+ * @remarks
690
+ *
691
+ * The range of values is from 0 to 18_446_744_073_709_551_615, inclusive.
692
+ *
693
+ * However, it may run into precision issues past `9_007_199_254_740_991`
694
+ *
695
+ * @param name The name of the property
696
+ * @returns The modified schema
697
+ */
698
+ uint64(name) {
699
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint64);
700
+ }
701
+ /**
702
+ * Adds a 32-bit big integer property to the schema.
703
+ *
704
+ * @remarks
705
+ *
706
+ * The range of values is from -2_147_483_648n to 2_147_483_647n, inclusive.
707
+ *
708
+ * @param name The name of the property
709
+ * @returns The modified schema
710
+ */
711
+ bigInt32(name) {
712
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bigInt32);
713
+ }
714
+ /**
715
+ * Adds a 32-bit big integer property to the schema.
716
+ *
717
+ * @remarks
718
+ *
719
+ * The range of values is from 0n to 4_294_967_295n, inclusive.
720
+ *
721
+ * @param name The name of the property
722
+ * @returns The modified schema
723
+ */
724
+ bigUint32(name) {
725
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bigUint32);
726
+ }
727
+ /**
728
+ * Adds a 64-bit big integer property to the schema.
729
+ *
730
+ * @remarks
731
+ *
732
+ * The range of values is from -9_223_372_036_854_775_808n to 9_223_372_036_854_775_807n, inclusive.
733
+ *
734
+ * @param name The name of the property
735
+ * @returns The modified schema
736
+ */
737
+ bigInt64(name) {
738
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bigInt64);
739
+ }
740
+ /**
741
+ * Adds a 64-bit big integer property to the schema.
742
+ *
743
+ * @remarks
744
+ *
745
+ * The range of values is from 0n to 18_446_744_073_709_551_615n, inclusive.
746
+ *
747
+ * @param name The name of the property
748
+ * @returns The modified schema
749
+ */
750
+ bigUint64(name) {
751
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bigUint64);
752
+ }
753
+ /**
754
+ * Adds a 32-bit floating point number property to the schema.
755
+ *
756
+ * @remarks
757
+ *
758
+ * The range of values is from -3.4028234663852886e+38 to 3.4028234663852886e+38, inclusive.
759
+ *
760
+ * @param name The name of the property
761
+ * @returns The modified schema
762
+ */
763
+ float32(name) {
764
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.float32);
765
+ }
766
+ /**
767
+ * Adds a 64-bit floating point number property to the schema.
768
+ *
769
+ * @remarks
770
+ *
771
+ * The range of values is from -1.7976931348623157e+308 to 1.7976931348623157e+308, inclusive.
772
+ *
773
+ * @param name The name of the property
774
+ * @returns The modified schema
775
+ */
776
+ float64(name) {
777
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.float64);
778
+ }
779
+ /**
780
+ * Adds a 64-bit big integer property to the schema, similar to {@link Schema.bigUint64}.
781
+ *
782
+ * @remarks
783
+ *
784
+ * The range of values is from 0n to 18_446_744_073_709_551_615n, inclusive.
785
+ *
786
+ * @param name The name of the property
787
+ * @returns The modified schema
788
+ */
789
+ snowflake(name) {
790
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.snowflake);
791
+ }
792
+ /**
793
+ * Iterates over the schema's property names.
794
+ *
795
+ * @returns An iterator for the schema's property names
796
+ */
797
+ keys() {
798
+ return __privateGet(this, _types).keys();
799
+ }
800
+ /**
801
+ * Iterates over the schema's property values
802
+ *
803
+ * @returns An iterator for the schema's property values
804
+ */
805
+ values() {
806
+ return __privateGet(this, _types).values();
807
+ }
808
+ /**
809
+ * Iterates over the schema's property entries
810
+ *
811
+ * @returns An iterator for the schema's property entries
812
+ */
813
+ entries() {
814
+ return __privateGet(this, _types).entries();
815
+ }
816
+ /**
817
+ * Iterates over the schema's property entries
818
+ *
819
+ * @returns An iterator for the schema's property entries
820
+ */
821
+ [Symbol.iterator]() {
822
+ return this.entries();
823
+ }
824
+ };
825
+ _id = new WeakMap();
826
+ _types = new WeakMap();
827
+ _bitSize = new WeakMap();
828
+ _Schema_instances = new WeakSet();
829
+ addType_fn = /* @__PURE__ */ __name(function(name, type) {
830
+ if (__privateGet(this, _types).has(name)) {
831
+ throw new Error(`Schema with id ${__privateGet(this, _id)} already has a property with name "${name}"`);
832
+ }
833
+ __privateGet(this, _types).set(name, type);
834
+ if (type.BIT_SIZE === null) {
835
+ __privateSet(this, _bitSize, null);
836
+ } else if (__privateGet(this, _bitSize) !== null) {
837
+ __privateSet(this, _bitSize, __privateGet(this, _bitSize) + type.BIT_SIZE);
838
+ }
839
+ return this;
840
+ }, "#addType");
841
+ __name(_Schema, "Schema");
842
+ var Schema = _Schema;
843
+
844
+ // src/lib/UnalignedUint16Array.ts
845
+ var ConverterUint8 = new Uint8Array(8);
846
+ var ConverterUint16 = new Uint16Array(ConverterUint8.buffer);
847
+ var ConverterUint32 = new Uint32Array(ConverterUint8.buffer);
848
+ var ConverterUint64 = new BigUint64Array(ConverterUint8.buffer);
849
+ var ConverterInt32 = new Int32Array(ConverterUint8.buffer);
850
+ var ConverterInt64 = new BigInt64Array(ConverterUint8.buffer);
851
+ var ConverterFloat = new Float32Array(ConverterUint8.buffer);
852
+ var ConverterDouble = new Float64Array(ConverterUint8.buffer);
853
+ var _buffer, _bitLength, _wordIndex, _wordLength, _UnalignedUint16Array_instances, readBit_fn, readByte_fn, bufferRead16_fn, bufferRead32_fn, bufferRead64_fn, writeBit_fn, bufferWrite16_fn;
854
+ var _UnalignedUint16Array = class _UnalignedUint16Array {
855
+ constructor(maxLength) {
856
+ __privateAdd(this, _UnalignedUint16Array_instances);
857
+ __privateAdd(this, _buffer);
858
+ __privateAdd(this, _bitLength, 0);
859
+ __privateAdd(this, _wordIndex, 0);
860
+ __privateAdd(this, _wordLength, 0);
861
+ __privateSet(this, _buffer, new Uint16Array(maxLength));
862
+ }
863
+ get maxLength() {
864
+ return __privateGet(this, _buffer).length;
865
+ }
866
+ get maxBitLength() {
867
+ return __privateGet(this, _buffer).length * 16;
868
+ }
869
+ get length() {
870
+ return __privateGet(this, _wordLength);
871
+ }
872
+ get bitLength() {
873
+ return __privateGet(this, _bitLength);
874
+ }
875
+ writeBit(value) {
876
+ __privateMethod(this, _UnalignedUint16Array_instances, writeBit_fn).call(this, value);
877
+ }
878
+ writeInt2(value) {
879
+ this.writeBit(value & 1);
880
+ this.writeBit(value >> 1);
881
+ }
882
+ writeInt4(value) {
883
+ this.writeInt2(value & 3);
884
+ this.writeInt2(value >> 2);
885
+ }
886
+ writeInt8(value) {
887
+ this.writeInt4(value & 15);
888
+ this.writeInt4(value >> 4);
889
+ }
890
+ writeInt16(value) {
891
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
892
+ }
893
+ writeInt32(value) {
894
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
895
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value >> 16);
896
+ }
897
+ writeInt64(value) {
898
+ this.writeBigInt64(BigInt(value));
899
+ }
900
+ writeBigInt32(value) {
901
+ ConverterInt64[0] = value;
902
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
903
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
904
+ }
905
+ writeBigInt64(value) {
906
+ ConverterInt64[0] = value;
907
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
908
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
909
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
910
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
911
+ }
912
+ writeFloat32(value) {
913
+ ConverterFloat[0] = value;
914
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
915
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
916
+ }
917
+ writeFloat64(value) {
918
+ ConverterDouble[0] = value;
919
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
920
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
921
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
922
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
923
+ }
924
+ readBit(offset) {
925
+ const ptr = Pointer.from(offset);
926
+ return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
927
+ }
928
+ readInt2(offset) {
929
+ return this.readUint2(offset) << 30 >> 30;
930
+ }
931
+ readUint2(offset) {
932
+ const ptr = Pointer.from(offset);
933
+ return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
934
+ }
935
+ readInt4(offset) {
936
+ return this.readUint4(offset) << 28 >> 28;
937
+ }
938
+ readUint4(offset) {
939
+ const ptr = Pointer.from(offset);
940
+ 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;
941
+ }
942
+ readInt8(offset) {
943
+ return this.readUint8(offset) << 24 >> 24;
944
+ }
945
+ readUint8(offset) {
946
+ const ptr = Pointer.from(offset);
947
+ return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
948
+ }
949
+ readInt16(offset) {
950
+ return this.readUint16(offset) << 16 >> 16;
951
+ }
952
+ readUint16(offset) {
953
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead16_fn).call(this, Pointer.from(offset));
954
+ return ConverterUint16[0];
955
+ }
956
+ readInt32(offset) {
957
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
958
+ return ConverterInt32[0];
959
+ }
960
+ readUint32(offset) {
961
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
962
+ return ConverterUint32[0];
963
+ }
964
+ readInt64(offset) {
965
+ return Number(this.readBigInt64(offset));
966
+ }
967
+ readUint64(offset) {
968
+ return Number(this.readBigUint64(offset));
969
+ }
970
+ readBigInt32(offset) {
971
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
972
+ return BigInt(ConverterInt32[0]);
973
+ }
974
+ readBigUint32(offset) {
975
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
976
+ return BigInt(ConverterUint32[0]);
977
+ }
978
+ readBigInt64(offset) {
979
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
980
+ return ConverterInt64[0];
981
+ }
982
+ readBigUint64(offset) {
983
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
984
+ return ConverterUint64[0];
985
+ }
986
+ readFloat32(offset) {
987
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
988
+ return ConverterFloat[0];
989
+ }
990
+ readFloat64(offset) {
991
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
992
+ return ConverterDouble[0];
993
+ }
994
+ toString() {
995
+ let result = "";
996
+ for (let i = 0; i < this.length; i++) {
997
+ result += String.fromCharCode(__privateGet(this, _buffer)[i]);
998
+ }
999
+ return result;
1000
+ }
1001
+ toArray() {
1002
+ return __privateGet(this, _buffer).slice(0, this.length);
1003
+ }
1004
+ static from(value) {
1005
+ if (value instanceof _UnalignedUint16Array) return value;
1006
+ const buffer = new _UnalignedUint16Array(value.length);
1007
+ for (let i = 0; i < value.length; i++) {
1008
+ __privateGet(buffer, _buffer)[i] = value.charCodeAt(i);
1009
+ }
1010
+ __privateSet(buffer, _bitLength, value.length << 4);
1011
+ return buffer;
1012
+ }
1013
+ };
1014
+ _buffer = new WeakMap();
1015
+ _bitLength = new WeakMap();
1016
+ _wordIndex = new WeakMap();
1017
+ _wordLength = new WeakMap();
1018
+ _UnalignedUint16Array_instances = new WeakSet();
1019
+ readBit_fn = /* @__PURE__ */ __name(function(pointer) {
1020
+ const bitOffset = pointer.value;
1021
+ const index = bitOffset >> 4;
1022
+ const bitIndex = bitOffset & 15;
1023
+ pointer.add(1);
1024
+ return __privateGet(this, _buffer)[index] >> bitIndex & 1;
1025
+ }, "#readBit");
1026
+ readByte_fn = /* @__PURE__ */ __name(function(ptr) {
1027
+ 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;
1028
+ }, "#readByte");
1029
+ bufferRead16_fn = /* @__PURE__ */ __name(function(ptr) {
1030
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1031
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1032
+ }, "#bufferRead16");
1033
+ bufferRead32_fn = /* @__PURE__ */ __name(function(ptr) {
1034
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1035
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1036
+ ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1037
+ ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1038
+ }, "#bufferRead32");
1039
+ bufferRead64_fn = /* @__PURE__ */ __name(function(ptr) {
1040
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1041
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1042
+ ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1043
+ ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1044
+ ConverterUint8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1045
+ ConverterUint8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1046
+ ConverterUint8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1047
+ ConverterUint8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1048
+ }, "#bufferRead64");
1049
+ writeBit_fn = /* @__PURE__ */ __name(function(value) {
1050
+ if (__privateGet(this, _wordIndex) === this.maxLength) {
1051
+ throw new RangeError(`The buffer is full`);
1052
+ }
1053
+ if (value) {
1054
+ const index = __privateGet(this, _wordIndex);
1055
+ const bitIndex = this.bitLength & 15;
1056
+ __privateGet(this, _buffer)[index] |= 1 << bitIndex;
1057
+ }
1058
+ if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordLength)._++;
1059
+ __privateWrapper(this, _bitLength)._++;
1060
+ if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordIndex)._++;
1061
+ }, "#writeBit");
1062
+ bufferWrite16_fn = /* @__PURE__ */ __name(function(value) {
1063
+ const wordIndex = __privateGet(this, _wordIndex);
1064
+ const bitIndex = this.bitLength & 15;
1065
+ if (wordIndex + (bitIndex === 0 ? 0 : 1) === this.maxLength) {
1066
+ throw new RangeError(`The buffer is full`);
1067
+ }
1068
+ if (bitIndex === 0) {
1069
+ __privateGet(this, _buffer)[wordIndex] = value;
1070
+ } else {
1071
+ value &= 65535;
1072
+ __privateGet(this, _buffer)[wordIndex] |= value << bitIndex;
1073
+ __privateGet(this, _buffer)[wordIndex + 1] = value >> 16 - bitIndex;
1074
+ }
1075
+ __privateSet(this, _bitLength, __privateGet(this, _bitLength) + 16);
1076
+ __privateWrapper(this, _wordIndex)._++;
1077
+ __privateWrapper(this, _wordLength)._++;
1078
+ }, "#bufferWrite16");
1079
+ __name(_UnalignedUint16Array, "UnalignedUint16Array");
1080
+ var UnalignedUint16Array = _UnalignedUint16Array;
1081
+
1082
+ // src/lib/schema/SchemaStore.ts
1083
+ var _schemas;
1084
+ var _SchemaStore = class _SchemaStore {
1085
+ /**
1086
+ * Creates a new schema store
1087
+ *
1088
+ * @param defaultMaximumArrayLength The default maximum array length for schemas
1089
+ */
1090
+ constructor(defaultMaximumArrayLength = 100) {
1091
+ /**
1092
+ * The default maximum array length for schemas
1093
+ */
1094
+ __publicField(this, "defaultMaximumArrayLength");
1095
+ __privateAdd(this, _schemas, /* @__PURE__ */ new Map());
1096
+ this.defaultMaximumArrayLength = defaultMaximumArrayLength;
1097
+ }
1098
+ /**
1099
+ * Adds a schema to the store
1100
+ *
1101
+ * @param schema The schema to add to the store
1102
+ * @returns The modified store
1103
+ *
1104
+ * @remarks
1105
+ *
1106
+ * An error will be thrown if a schema with the same id already exists in the store.
1107
+ */
1108
+ add(schema) {
1109
+ if (__privateGet(this, _schemas).has(schema.id)) {
1110
+ throw new Error(`Schema with id ${schema.id} already exists`);
1111
+ }
1112
+ __privateGet(this, _schemas).set(schema.id, schema);
1113
+ return this;
1114
+ }
1115
+ /**
1116
+ * Gets a schema from the store
1117
+ *
1118
+ * @param id The id of the schema to get
1119
+ * @returns The schema with the given id
1120
+ *
1121
+ * @remarks
1122
+ *
1123
+ * An error will be thrown if a schema with the given id does not exist in the store.
1124
+ */
1125
+ get(id) {
1126
+ const schema = __privateGet(this, _schemas).get(id);
1127
+ if (!schema) throw new Error(`Schema with id ${id} does not exist`);
1128
+ return schema;
1129
+ }
1130
+ /**
1131
+ * Serializes a value using the schema with the given id
1132
+ *
1133
+ * @param id The id of the schema to use for serialization
1134
+ * @param value The value to serialize
1135
+ * @returns The serialized buffer
1136
+ */
1137
+ serialize(id, value) {
1138
+ const schema = this.get(id);
1139
+ const buffer = new UnalignedUint16Array(schema.bitSize ?? this.defaultMaximumArrayLength);
1140
+ schema.serialize(buffer, value);
1141
+ return buffer;
1142
+ }
1143
+ /**
1144
+ * Deserializes a buffer
1145
+ *
1146
+ * @param buffer The buffer to deserialize
1147
+ * @returns The resolved value, including the id of the schema used for deserialization
1148
+ */
1149
+ deserialize(buffer) {
1150
+ buffer = UnalignedUint16Array.from(buffer);
1151
+ const pointer = new Pointer();
1152
+ const id = buffer.readInt16(pointer);
1153
+ const schema = this.get(id);
1154
+ return { id, data: schema.deserialize(buffer, pointer) };
1155
+ }
1156
+ /**
1157
+ * Iterates over the stores's schema identifiers.
1158
+ *
1159
+ * @returns An iterator for the stores's schema identifiers
1160
+ */
1161
+ keys() {
1162
+ return __privateGet(this, _schemas).keys();
1163
+ }
1164
+ /**
1165
+ * Iterates over the stores's schemas.
1166
+ *
1167
+ * @returns An iterator for the stores's schemas
1168
+ */
1169
+ values() {
1170
+ return __privateGet(this, _schemas).values();
1171
+ }
1172
+ /**
1173
+ * Iterates over the stores's schema entries.
1174
+ *
1175
+ * @returns An iterator for the stores's schema entries
1176
+ */
1177
+ entries() {
1178
+ return __privateGet(this, _schemas).entries();
1179
+ }
1180
+ /**
1181
+ * Iterates over the stores's schema entries.
1182
+ *
1183
+ * @returns An iterator for the stores's schema entries
1184
+ */
1185
+ [Symbol.iterator]() {
1186
+ return this.entries();
1187
+ }
1188
+ };
1189
+ _schemas = new WeakMap();
1190
+ __name(_SchemaStore, "SchemaStore");
1191
+ var SchemaStore = _SchemaStore;
1192
+
1193
+ // src/lib/utilities.ts
1194
+ function toUTF16(buffer) {
1195
+ let result = "";
1196
+ for (const value of new Uint16Array(buffer.buffer)) {
1197
+ result += String.fromCharCode(value);
1198
+ }
1199
+ return result;
1200
+ }
1201
+ __name(toUTF16, "toUTF16");
1202
+ function fromUTF16(buffer) {
1203
+ const result = new Uint16Array(buffer.length);
1204
+ for (let i = 0; i < buffer.length; i++) {
1205
+ result[i] = buffer.charCodeAt(i);
1206
+ }
1207
+ return result;
1208
+ }
1209
+ __name(fromUTF16, "fromUTF16");
1210
+
1211
+ exports.ArrayType = ArrayType;
1212
+ exports.BigInt32Type = BigInt32Type;
1213
+ exports.BigInt64Type = BigInt64Type;
1214
+ exports.BigUint32Type = BigUint32Type;
1215
+ exports.BigUint64Type = BigUint64Type;
1216
+ exports.BitType = BitType;
1217
+ exports.BooleanType = BooleanType;
1218
+ exports.FixedLengthArrayType = FixedLengthArrayType;
1219
+ exports.Float32Type = Float32Type;
1220
+ exports.Float64Type = Float64Type;
1221
+ exports.Int16Type = Int16Type;
1222
+ exports.Int2Type = Int2Type;
1223
+ exports.Int32Type = Int32Type;
1224
+ exports.Int4Type = Int4Type;
1225
+ exports.Int64Type = Int64Type;
1226
+ exports.Int8Type = Int8Type;
1227
+ exports.Pointer = Pointer;
1228
+ exports.Schema = Schema;
1229
+ exports.SchemaStore = SchemaStore;
1230
+ exports.SnowflakeType = SnowflakeType;
1231
+ exports.StringType = StringType;
1232
+ exports.Uint16Type = Uint16Type;
1233
+ exports.Uint2Type = Uint2Type;
1234
+ exports.Uint32Type = Uint32Type;
1235
+ exports.Uint4Type = Uint4Type;
1236
+ exports.Uint64Type = Uint64Type;
1237
+ exports.Uint8Type = Uint8Type;
1238
+ exports.UnalignedUint16Array = UnalignedUint16Array;
1239
+ exports.fromUTF16 = fromUTF16;
1240
+ exports.t = t;
1241
+ exports.toUTF16 = toUTF16;
1242
+ //# sourceMappingURL=index.cjs.map
1243
+ //# sourceMappingURL=index.cjs.map