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