@sapphire/string-store 1.1.0-next.7c2bed20 → 1.1.0-next.8627eb32

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.
@@ -87,7 +87,7 @@ var SapphireStringStore = (function (exports) {
87
87
  }
88
88
  },
89
89
  deserialize(buffer, pointer) {
90
- const length = buffer.readInt16(pointer);
90
+ const length = buffer.readUint16(pointer);
91
91
  const value = [];
92
92
  for (let i = 0; i < length; i++) {
93
93
  value.push(type.deserialize(buffer, pointer));
@@ -121,6 +121,28 @@ var SapphireStringStore = (function (exports) {
121
121
  BIT_SIZE: 64
122
122
  };
123
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
+
124
146
  // src/lib/types/Bit.ts
125
147
  var BitType = {
126
148
  serialize(buffer, value) {
@@ -260,7 +282,7 @@ var SapphireStringStore = (function (exports) {
260
282
  buffer.writeBigInt64(BigInt(value));
261
283
  },
262
284
  deserialize(buffer, offset) {
263
- return buffer.readBigInt64(offset);
285
+ return buffer.readBigUint64(offset);
264
286
  },
265
287
  BIT_SIZE: 64
266
288
  };
@@ -287,6 +309,100 @@ var SapphireStringStore = (function (exports) {
287
309
  BIT_SIZE: null
288
310
  };
289
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
+
290
406
  // src/lib/schema/Schema.ts
291
407
  var _id, _types, _bitSize, _Schema_instances, addType_fn;
292
408
  var _Schema = class _Schema {
@@ -381,7 +497,7 @@ var SapphireStringStore = (function (exports) {
381
497
  * @returns The modified schema
382
498
  */
383
499
  array(name, type) {
384
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, ArrayType(type));
500
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.array(type));
385
501
  }
386
502
  /**
387
503
  * Adds a fixed length array property to the schema.
@@ -394,7 +510,7 @@ var SapphireStringStore = (function (exports) {
394
510
  * @returns The modified schema
395
511
  */
396
512
  fixedLengthArray(name, type, length) {
397
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, FixedLengthArrayType(type, length));
513
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.fixedLengthArray(type, length));
398
514
  }
399
515
  /**
400
516
  * Adds a string property to the schema.
@@ -403,7 +519,7 @@ var SapphireStringStore = (function (exports) {
403
519
  * @returns The modified schema
404
520
  */
405
521
  string(name) {
406
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, StringType);
522
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.string);
407
523
  }
408
524
  /**
409
525
  * Adds a boolean property to the schema.
@@ -412,7 +528,7 @@ var SapphireStringStore = (function (exports) {
412
528
  * @returns The modified schema
413
529
  */
414
530
  boolean(name) {
415
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, BooleanType);
531
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.boolean);
416
532
  }
417
533
  /**
418
534
  * Adds a bit property to the schema.
@@ -421,106 +537,258 @@ var SapphireStringStore = (function (exports) {
421
537
  * @returns The modified schema
422
538
  */
423
539
  bit(name) {
424
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, BitType);
540
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bit);
425
541
  }
426
542
  /**
427
543
  * Adds a 2-bit integer property to the schema.
428
544
  *
545
+ * @remarks
546
+ *
547
+ * The range of values is from -2 to 1, inclusive.
548
+ *
429
549
  * @param name The name of the property
430
550
  * @returns The modified schema
431
551
  */
432
552
  int2(name) {
433
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int2Type);
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);
434
567
  }
435
568
  /**
436
569
  * Adds a 4-bit integer property to the schema.
437
570
  *
571
+ * @remarks
572
+ *
573
+ * The range of values is from -8 to 7, inclusive.
574
+ *
438
575
  * @param name The name of the property
439
576
  * @returns The modified schema
440
577
  */
441
578
  int4(name) {
442
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int4Type);
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);
443
593
  }
444
594
  /**
445
595
  * Adds a 8-bit integer property to the schema.
446
596
  *
597
+ * @remarks
598
+ *
599
+ * The range of values is from -128 to 127, inclusive.
600
+ *
447
601
  * @param name The name of the property
448
602
  * @returns The modified schema
449
603
  */
450
604
  int8(name) {
451
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int8Type);
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);
452
619
  }
453
620
  /**
454
621
  * Adds a 16-bit integer property to the schema.
455
622
  *
623
+ * @remarks
624
+ *
625
+ * The range of values is from -32768 to 32767, inclusive.
626
+ *
456
627
  * @param name The name of the property
457
628
  * @returns The modified schema
458
629
  */
459
630
  int16(name) {
460
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int16Type);
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);
461
645
  }
462
646
  /**
463
647
  * Adds a 32-bit integer property to the schema.
464
648
  *
649
+ * @remarks
650
+ *
651
+ * The range of values is from -2_147_483_648 to 2_147_483_647, inclusive.
652
+ *
465
653
  * @param name The name of the property
466
654
  * @returns The modified schema
467
655
  */
468
656
  int32(name) {
469
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int32Type);
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);
470
671
  }
471
672
  /**
472
673
  * Adds a 64-bit integer property to the schema.
473
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
+ *
474
681
  * @param name The name of the property
475
682
  * @returns The modified schema
476
683
  */
477
684
  int64(name) {
478
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int64Type);
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);
479
701
  }
480
702
  /**
481
703
  * Adds a 32-bit big integer property to the schema.
482
704
  *
705
+ * @remarks
706
+ *
707
+ * The range of values is from -2_147_483_648n to 2_147_483_647n, inclusive.
708
+ *
483
709
  * @param name The name of the property
484
710
  * @returns The modified schema
485
711
  */
486
712
  bigInt32(name) {
487
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, BigInt32Type);
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);
488
727
  }
489
728
  /**
490
729
  * Adds a 64-bit big integer property to the schema.
491
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
+ *
492
735
  * @param name The name of the property
493
736
  * @returns The modified schema
494
737
  */
495
738
  bigInt64(name) {
496
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, BigInt64Type);
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);
497
753
  }
498
754
  /**
499
755
  * Adds a 32-bit floating point number property to the schema.
500
756
  *
757
+ * @remarks
758
+ *
759
+ * The range of values is from -3.4028234663852886e+38 to 3.4028234663852886e+38, inclusive.
760
+ *
501
761
  * @param name The name of the property
502
762
  * @returns The modified schema
503
763
  */
504
764
  float32(name) {
505
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Float32Type);
765
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.float32);
506
766
  }
507
767
  /**
508
768
  * Adds a 64-bit floating point number property to the schema.
509
769
  *
770
+ * @remarks
771
+ *
772
+ * The range of values is from -1.7976931348623157e+308 to 1.7976931348623157e+308, inclusive.
773
+ *
510
774
  * @param name The name of the property
511
775
  * @returns The modified schema
512
776
  */
513
777
  float64(name) {
514
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Float64Type);
778
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.float64);
515
779
  }
516
780
  /**
517
- * Adds a 64-bit big integer property to the schema, similar to {@link Schema.bigInt64}.
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.
518
786
  *
519
787
  * @param name The name of the property
520
788
  * @returns The modified schema
521
789
  */
522
790
  snowflake(name) {
523
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, SnowflakeType);
791
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.snowflake);
524
792
  }
525
793
  /**
526
794
  * Iterates over the schema's property names.
@@ -575,10 +843,15 @@ var SapphireStringStore = (function (exports) {
575
843
  var Schema = _Schema;
576
844
 
577
845
  // src/lib/UnalignedUint16Array.ts
578
- var Converter8 = new Uint8Array(8);
579
- var ConverterFloat = new Float32Array(Converter8.buffer);
580
- var ConverterDouble = new Float64Array(Converter8.buffer);
581
- var _buffer, _bitLength, _wordIndex, _wordLength, _UnalignedUint16Array_instances, readBit_fn, readByte_fn, writeBit_fn;
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;
582
855
  var _UnalignedUint16Array = class _UnalignedUint16Array {
583
856
  constructor(maxLength) {
584
857
  __privateAdd(this, _UnalignedUint16Array_instances);
@@ -616,94 +889,107 @@ var SapphireStringStore = (function (exports) {
616
889
  this.writeInt4(value >> 4);
617
890
  }
618
891
  writeInt16(value) {
619
- this.writeInt8(value & 255);
620
- this.writeInt8(value >> 8);
892
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
621
893
  }
622
894
  writeInt32(value) {
623
- this.writeInt16(value & 65535);
624
- this.writeInt16(value >> 16);
895
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
896
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value >> 16);
625
897
  }
626
898
  writeInt64(value) {
627
899
  this.writeBigInt64(BigInt(value));
628
900
  }
629
901
  writeBigInt32(value) {
630
- this.writeInt16(Number(value & 0xffffn));
631
- this.writeInt16(Number(value >> 16n));
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]);
632
905
  }
633
906
  writeBigInt64(value) {
634
- this.writeInt32(Number(value & 0xffffffffn));
635
- this.writeInt32(Number(value >> 32n));
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]);
636
912
  }
637
913
  writeFloat32(value) {
638
914
  ConverterFloat[0] = value;
639
- this.writeInt8(Converter8[0]);
640
- this.writeInt8(Converter8[1]);
641
- this.writeInt8(Converter8[2]);
642
- this.writeInt8(Converter8[3]);
915
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
916
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
643
917
  }
644
918
  writeFloat64(value) {
645
919
  ConverterDouble[0] = value;
646
- this.writeInt8(Converter8[0]);
647
- this.writeInt8(Converter8[1]);
648
- this.writeInt8(Converter8[2]);
649
- this.writeInt8(Converter8[3]);
650
- this.writeInt8(Converter8[4]);
651
- this.writeInt8(Converter8[5]);
652
- this.writeInt8(Converter8[6]);
653
- this.writeInt8(Converter8[7]);
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]);
654
924
  }
655
925
  readBit(offset) {
656
926
  const ptr = Pointer.from(offset);
657
927
  return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
658
928
  }
659
929
  readInt2(offset) {
930
+ return this.readUint2(offset) << 30 >> 30;
931
+ }
932
+ readUint2(offset) {
660
933
  const ptr = Pointer.from(offset);
661
934
  return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
662
935
  }
663
936
  readInt4(offset) {
937
+ return this.readUint4(offset) << 28 >> 28;
938
+ }
939
+ readUint4(offset) {
664
940
  const ptr = Pointer.from(offset);
665
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;
666
942
  }
667
943
  readInt8(offset) {
944
+ return this.readUint8(offset) << 24 >> 24;
945
+ }
946
+ readUint8(offset) {
668
947
  const ptr = Pointer.from(offset);
669
948
  return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
670
949
  }
671
950
  readInt16(offset) {
672
- const ptr = Pointer.from(offset);
673
- return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr) << 8;
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];
674
956
  }
675
957
  readInt32(offset) {
676
- return Number(this.readBigInt32(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];
677
964
  }
678
965
  readInt64(offset) {
679
966
  return Number(this.readBigInt64(offset));
680
967
  }
968
+ readUint64(offset) {
969
+ return Number(this.readBigUint64(offset));
970
+ }
681
971
  readBigInt32(offset) {
682
- const ptr = Pointer.from(offset);
683
- return BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 8n | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 16n | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 24n;
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]);
684
978
  }
685
979
  readBigInt64(offset) {
686
- const ptr = Pointer.from(offset);
687
- return BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 8n | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 16n | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 24n | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 32n | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 40n | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 48n | BigInt(__privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr)) << 56n;
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];
688
986
  }
689
987
  readFloat32(offset) {
690
- const ptr = Pointer.from(offset);
691
- Converter8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
692
- Converter8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
693
- Converter8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
694
- Converter8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
988
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
695
989
  return ConverterFloat[0];
696
990
  }
697
991
  readFloat64(offset) {
698
- const ptr = Pointer.from(offset);
699
- Converter8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
700
- Converter8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
701
- Converter8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
702
- Converter8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
703
- Converter8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
704
- Converter8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
705
- Converter8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
706
- Converter8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
992
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
707
993
  return ConverterDouble[0];
708
994
  }
709
995
  toString() {
@@ -741,6 +1027,26 @@ var SapphireStringStore = (function (exports) {
741
1027
  readByte_fn = /* @__PURE__ */ __name(function(ptr) {
742
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;
743
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");
744
1050
  writeBit_fn = /* @__PURE__ */ __name(function(value) {
745
1051
  if (__privateGet(this, _wordIndex) === this.maxLength) {
746
1052
  throw new RangeError(`The buffer is full`);
@@ -754,6 +1060,23 @@ var SapphireStringStore = (function (exports) {
754
1060
  __privateWrapper(this, _bitLength)._++;
755
1061
  if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordIndex)._++;
756
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");
757
1080
  __name(_UnalignedUint16Array, "UnalignedUint16Array");
758
1081
  var UnalignedUint16Array = _UnalignedUint16Array;
759
1082
 
@@ -868,9 +1191,29 @@ var SapphireStringStore = (function (exports) {
868
1191
  __name(_SchemaStore, "SchemaStore");
869
1192
  var SchemaStore = _SchemaStore;
870
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
+
871
1212
  exports.ArrayType = ArrayType;
872
1213
  exports.BigInt32Type = BigInt32Type;
873
1214
  exports.BigInt64Type = BigInt64Type;
1215
+ exports.BigUint32Type = BigUint32Type;
1216
+ exports.BigUint64Type = BigUint64Type;
874
1217
  exports.BitType = BitType;
875
1218
  exports.BooleanType = BooleanType;
876
1219
  exports.FixedLengthArrayType = FixedLengthArrayType;
@@ -887,7 +1230,16 @@ var SapphireStringStore = (function (exports) {
887
1230
  exports.SchemaStore = SchemaStore;
888
1231
  exports.SnowflakeType = SnowflakeType;
889
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;
890
1239
  exports.UnalignedUint16Array = UnalignedUint16Array;
1240
+ exports.fromUTF16 = fromUTF16;
1241
+ exports.t = t;
1242
+ exports.toUTF16 = toUTF16;
891
1243
 
892
1244
  return exports;
893
1245