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