@sapphire/string-store 1.1.0-next.7c2bed20 → 1.1.0-next.8810833c

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.
@@ -86,7 +86,7 @@ function ArrayType(type) {
86
86
  }
87
87
  },
88
88
  deserialize(buffer, pointer) {
89
- const length = buffer.readInt16(pointer);
89
+ const length = buffer.readUint16(pointer);
90
90
  const value = [];
91
91
  for (let i = 0; i < length; i++) {
92
92
  value.push(type.deserialize(buffer, pointer));
@@ -120,6 +120,28 @@ var BigInt64Type = {
120
120
  BIT_SIZE: 64
121
121
  };
122
122
 
123
+ // src/lib/types/BigUint32.ts
124
+ var BigUint32Type = {
125
+ serialize(buffer, value) {
126
+ buffer.writeBigInt32(value);
127
+ },
128
+ deserialize(buffer, pointer) {
129
+ return buffer.readBigUint32(pointer);
130
+ },
131
+ BIT_SIZE: 32
132
+ };
133
+
134
+ // src/lib/types/BigUint64.ts
135
+ var BigUint64Type = {
136
+ serialize(buffer, value) {
137
+ buffer.writeBigInt64(value);
138
+ },
139
+ deserialize(buffer, pointer) {
140
+ return buffer.readBigUint64(pointer);
141
+ },
142
+ BIT_SIZE: 64
143
+ };
144
+
123
145
  // src/lib/types/Bit.ts
124
146
  var BitType = {
125
147
  serialize(buffer, value) {
@@ -259,7 +281,7 @@ var SnowflakeType = {
259
281
  buffer.writeBigInt64(BigInt(value));
260
282
  },
261
283
  deserialize(buffer, offset) {
262
- return buffer.readBigInt64(offset);
284
+ return buffer.readBigUint64(offset);
263
285
  },
264
286
  BIT_SIZE: 64
265
287
  };
@@ -286,6 +308,100 @@ var StringType = {
286
308
  BIT_SIZE: null
287
309
  };
288
310
 
311
+ // src/lib/types/Uint16.ts
312
+ var Uint16Type = {
313
+ serialize(buffer, value) {
314
+ buffer.writeInt16(value);
315
+ },
316
+ deserialize(buffer, pointer) {
317
+ return buffer.readUint16(pointer);
318
+ },
319
+ BIT_SIZE: 16
320
+ };
321
+
322
+ // src/lib/types/Uint2.ts
323
+ var Uint2Type = {
324
+ serialize(buffer, value) {
325
+ buffer.writeInt2(value);
326
+ },
327
+ deserialize(buffer, pointer) {
328
+ return buffer.readUint2(pointer);
329
+ },
330
+ BIT_SIZE: 2
331
+ };
332
+
333
+ // src/lib/types/Uint32.ts
334
+ var Uint32Type = {
335
+ serialize(buffer, value) {
336
+ buffer.writeInt32(value);
337
+ },
338
+ deserialize(buffer, pointer) {
339
+ return buffer.readUint32(pointer);
340
+ },
341
+ BIT_SIZE: 32
342
+ };
343
+
344
+ // src/lib/types/Uint4.ts
345
+ var Uint4Type = {
346
+ serialize(buffer, value) {
347
+ buffer.writeInt4(value);
348
+ },
349
+ deserialize(buffer, pointer) {
350
+ return buffer.readUint4(pointer);
351
+ },
352
+ BIT_SIZE: 4
353
+ };
354
+
355
+ // src/lib/types/Uint64.ts
356
+ var Uint64Type = {
357
+ serialize(buffer, value) {
358
+ buffer.writeInt64(value);
359
+ },
360
+ deserialize(buffer, pointer) {
361
+ return buffer.readUint64(pointer);
362
+ },
363
+ BIT_SIZE: 64
364
+ };
365
+
366
+ // src/lib/types/Uint8.ts
367
+ var Uint8Type = {
368
+ serialize(buffer, value) {
369
+ buffer.writeInt8(value);
370
+ },
371
+ deserialize(buffer, pointer) {
372
+ return buffer.readUint8(pointer);
373
+ },
374
+ BIT_SIZE: 8
375
+ };
376
+
377
+ // src/lib/types/index.ts
378
+ var t = {
379
+ array: ArrayType,
380
+ bigInt32: BigInt32Type,
381
+ bigInt64: BigInt64Type,
382
+ bigUint32: BigUint32Type,
383
+ bigUint64: BigUint64Type,
384
+ bit: BitType,
385
+ boolean: BooleanType,
386
+ fixedLengthArray: FixedLengthArrayType,
387
+ float32: Float32Type,
388
+ float64: Float64Type,
389
+ int16: Int16Type,
390
+ int2: Int2Type,
391
+ int32: Int32Type,
392
+ int4: Int4Type,
393
+ int64: Int64Type,
394
+ int8: Int8Type,
395
+ snowflake: SnowflakeType,
396
+ string: StringType,
397
+ uint16: Uint16Type,
398
+ uint2: Uint2Type,
399
+ uint32: Uint32Type,
400
+ uint4: Uint4Type,
401
+ uint64: Uint64Type,
402
+ uint8: Uint8Type
403
+ };
404
+
289
405
  // src/lib/schema/Schema.ts
290
406
  var _id, _types, _bitSize, _Schema_instances, addType_fn;
291
407
  var _Schema = class _Schema {
@@ -380,7 +496,7 @@ var _Schema = class _Schema {
380
496
  * @returns The modified schema
381
497
  */
382
498
  array(name, type) {
383
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, ArrayType(type));
499
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.array(type));
384
500
  }
385
501
  /**
386
502
  * Adds a fixed length array property to the schema.
@@ -393,7 +509,7 @@ var _Schema = class _Schema {
393
509
  * @returns The modified schema
394
510
  */
395
511
  fixedLengthArray(name, type, length) {
396
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, FixedLengthArrayType(type, length));
512
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.fixedLengthArray(type, length));
397
513
  }
398
514
  /**
399
515
  * Adds a string property to the schema.
@@ -402,7 +518,7 @@ var _Schema = class _Schema {
402
518
  * @returns The modified schema
403
519
  */
404
520
  string(name) {
405
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, StringType);
521
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.string);
406
522
  }
407
523
  /**
408
524
  * Adds a boolean property to the schema.
@@ -411,7 +527,7 @@ var _Schema = class _Schema {
411
527
  * @returns The modified schema
412
528
  */
413
529
  boolean(name) {
414
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, BooleanType);
530
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.boolean);
415
531
  }
416
532
  /**
417
533
  * Adds a bit property to the schema.
@@ -420,106 +536,258 @@ var _Schema = class _Schema {
420
536
  * @returns The modified schema
421
537
  */
422
538
  bit(name) {
423
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, BitType);
539
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bit);
424
540
  }
425
541
  /**
426
542
  * Adds a 2-bit integer property to the schema.
427
543
  *
544
+ * @remarks
545
+ *
546
+ * The range of values is from -2 to 1, inclusive.
547
+ *
428
548
  * @param name The name of the property
429
549
  * @returns The modified schema
430
550
  */
431
551
  int2(name) {
432
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int2Type);
552
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int2);
553
+ }
554
+ /**
555
+ * Adds a 2-bit unsigned integer property to the schema.
556
+ *
557
+ * @remarks
558
+ *
559
+ * The range of values is from 0 to 3, inclusive.
560
+ *
561
+ * @param name The name of the property
562
+ * @returns The modified schema
563
+ */
564
+ uint2(name) {
565
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint2);
433
566
  }
434
567
  /**
435
568
  * Adds a 4-bit integer property to the schema.
436
569
  *
570
+ * @remarks
571
+ *
572
+ * The range of values is from -8 to 7, inclusive.
573
+ *
437
574
  * @param name The name of the property
438
575
  * @returns The modified schema
439
576
  */
440
577
  int4(name) {
441
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int4Type);
578
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int4);
579
+ }
580
+ /**
581
+ * Adds a 4-bit unsigned integer property to the schema.
582
+ *
583
+ * @remarks
584
+ *
585
+ * The range of values is from 0 to 15, inclusive.
586
+ *
587
+ * @param name The name of the property
588
+ * @returns The modified schema
589
+ */
590
+ uint4(name) {
591
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint4);
442
592
  }
443
593
  /**
444
594
  * Adds a 8-bit integer property to the schema.
445
595
  *
596
+ * @remarks
597
+ *
598
+ * The range of values is from -128 to 127, inclusive.
599
+ *
446
600
  * @param name The name of the property
447
601
  * @returns The modified schema
448
602
  */
449
603
  int8(name) {
450
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int8Type);
604
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int8);
605
+ }
606
+ /**
607
+ * Adds a 8-bit unsigned integer property to the schema.
608
+ *
609
+ * @remarks
610
+ *
611
+ * The range of values is from 0 to 255, inclusive.
612
+ *
613
+ * @param name The name of the property
614
+ * @returns The modified schema
615
+ */
616
+ uint8(name) {
617
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint8);
451
618
  }
452
619
  /**
453
620
  * Adds a 16-bit integer property to the schema.
454
621
  *
622
+ * @remarks
623
+ *
624
+ * The range of values is from -32768 to 32767, inclusive.
625
+ *
455
626
  * @param name The name of the property
456
627
  * @returns The modified schema
457
628
  */
458
629
  int16(name) {
459
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int16Type);
630
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int16);
631
+ }
632
+ /**
633
+ * Adds a 16-bit unsigned integer property to the schema.
634
+ *
635
+ * @remarks
636
+ *
637
+ * The range of values is from 0 to 65535, inclusive.
638
+ *
639
+ * @param name The name of the property
640
+ * @returns The modified schema
641
+ */
642
+ uint16(name) {
643
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint16);
460
644
  }
461
645
  /**
462
646
  * Adds a 32-bit integer property to the schema.
463
647
  *
648
+ * @remarks
649
+ *
650
+ * The range of values is from -2_147_483_648 to 2_147_483_647, inclusive.
651
+ *
464
652
  * @param name The name of the property
465
653
  * @returns The modified schema
466
654
  */
467
655
  int32(name) {
468
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int32Type);
656
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int32);
657
+ }
658
+ /**
659
+ * Adds a 32-bit unsigned integer property to the schema.
660
+ *
661
+ * @remarks
662
+ *
663
+ * The range of values is from 0 to 4_294_967_295, inclusive.
664
+ *
665
+ * @param name The name of the property
666
+ * @returns The modified schema
667
+ */
668
+ uint32(name) {
669
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint32);
469
670
  }
470
671
  /**
471
672
  * Adds a 64-bit integer property to the schema.
472
673
  *
674
+ * @remarks
675
+ *
676
+ * The range of values is from -9_223_372_036_854_775_808 to 9_223_372_036_854_775_807, inclusive.
677
+ *
678
+ * However, it may run into precision issues past the range of `-9_007_199_254_740_991` to `9_007_199_254_740_991`
679
+ *
473
680
  * @param name The name of the property
474
681
  * @returns The modified schema
475
682
  */
476
683
  int64(name) {
477
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Int64Type);
684
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.int64);
685
+ }
686
+ /**
687
+ * Adds a 64-bit unsigned integer property to the schema.
688
+ *
689
+ * @remarks
690
+ *
691
+ * The range of values is from 0 to 18_446_744_073_709_551_615, inclusive.
692
+ *
693
+ * However, it may run into precision issues past `9_007_199_254_740_991`
694
+ *
695
+ * @param name The name of the property
696
+ * @returns The modified schema
697
+ */
698
+ uint64(name) {
699
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.uint64);
478
700
  }
479
701
  /**
480
702
  * Adds a 32-bit big integer property to the schema.
481
703
  *
704
+ * @remarks
705
+ *
706
+ * The range of values is from -2_147_483_648n to 2_147_483_647n, inclusive.
707
+ *
482
708
  * @param name The name of the property
483
709
  * @returns The modified schema
484
710
  */
485
711
  bigInt32(name) {
486
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, BigInt32Type);
712
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bigInt32);
713
+ }
714
+ /**
715
+ * Adds a 32-bit big integer property to the schema.
716
+ *
717
+ * @remarks
718
+ *
719
+ * The range of values is from 0n to 4_294_967_295n, inclusive.
720
+ *
721
+ * @param name The name of the property
722
+ * @returns The modified schema
723
+ */
724
+ bigUint32(name) {
725
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bigUint32);
487
726
  }
488
727
  /**
489
728
  * Adds a 64-bit big integer property to the schema.
490
729
  *
730
+ * @remarks
731
+ *
732
+ * The range of values is from -9_223_372_036_854_775_808n to 9_223_372_036_854_775_807n, inclusive.
733
+ *
491
734
  * @param name The name of the property
492
735
  * @returns The modified schema
493
736
  */
494
737
  bigInt64(name) {
495
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, BigInt64Type);
738
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bigInt64);
739
+ }
740
+ /**
741
+ * Adds a 64-bit big integer property to the schema.
742
+ *
743
+ * @remarks
744
+ *
745
+ * The range of values is from 0n to 18_446_744_073_709_551_615n, inclusive.
746
+ *
747
+ * @param name The name of the property
748
+ * @returns The modified schema
749
+ */
750
+ bigUint64(name) {
751
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.bigUint64);
496
752
  }
497
753
  /**
498
754
  * Adds a 32-bit floating point number property to the schema.
499
755
  *
756
+ * @remarks
757
+ *
758
+ * The range of values is from -3.4028234663852886e+38 to 3.4028234663852886e+38, inclusive.
759
+ *
500
760
  * @param name The name of the property
501
761
  * @returns The modified schema
502
762
  */
503
763
  float32(name) {
504
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Float32Type);
764
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.float32);
505
765
  }
506
766
  /**
507
767
  * Adds a 64-bit floating point number property to the schema.
508
768
  *
769
+ * @remarks
770
+ *
771
+ * The range of values is from -1.7976931348623157e+308 to 1.7976931348623157e+308, inclusive.
772
+ *
509
773
  * @param name The name of the property
510
774
  * @returns The modified schema
511
775
  */
512
776
  float64(name) {
513
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, Float64Type);
777
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.float64);
514
778
  }
515
779
  /**
516
- * Adds a 64-bit big integer property to the schema, similar to {@link Schema.bigInt64}.
780
+ * Adds a 64-bit big integer property to the schema, similar to {@link Schema.bigUint64}.
781
+ *
782
+ * @remarks
783
+ *
784
+ * The range of values is from 0n to 18_446_744_073_709_551_615n, inclusive.
517
785
  *
518
786
  * @param name The name of the property
519
787
  * @returns The modified schema
520
788
  */
521
789
  snowflake(name) {
522
- return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, SnowflakeType);
790
+ return __privateMethod(this, _Schema_instances, addType_fn).call(this, name, t.snowflake);
523
791
  }
524
792
  /**
525
793
  * Iterates over the schema's property names.
@@ -574,10 +842,15 @@ __name(_Schema, "Schema");
574
842
  var Schema = _Schema;
575
843
 
576
844
  // src/lib/UnalignedUint16Array.ts
577
- var Converter8 = new Uint8Array(8);
578
- var ConverterFloat = new Float32Array(Converter8.buffer);
579
- var ConverterDouble = new Float64Array(Converter8.buffer);
580
- var _buffer, _bitLength, _wordIndex, _wordLength, _UnalignedUint16Array_instances, readBit_fn, readByte_fn, writeBit_fn;
845
+ var ConverterUint8 = new Uint8Array(8);
846
+ var ConverterUint16 = new Uint16Array(ConverterUint8.buffer);
847
+ var ConverterUint32 = new Uint32Array(ConverterUint8.buffer);
848
+ var ConverterUint64 = new BigUint64Array(ConverterUint8.buffer);
849
+ var ConverterInt32 = new Int32Array(ConverterUint8.buffer);
850
+ var ConverterInt64 = new BigInt64Array(ConverterUint8.buffer);
851
+ var ConverterFloat = new Float32Array(ConverterUint8.buffer);
852
+ var ConverterDouble = new Float64Array(ConverterUint8.buffer);
853
+ var _buffer, _bitLength, _wordIndex, _wordLength, _UnalignedUint16Array_instances, readBit_fn, readByte_fn, bufferRead16_fn, bufferRead32_fn, bufferRead64_fn, writeBit_fn, bufferWrite16_fn;
581
854
  var _UnalignedUint16Array = class _UnalignedUint16Array {
582
855
  constructor(maxLength) {
583
856
  __privateAdd(this, _UnalignedUint16Array_instances);
@@ -615,94 +888,107 @@ var _UnalignedUint16Array = class _UnalignedUint16Array {
615
888
  this.writeInt4(value >> 4);
616
889
  }
617
890
  writeInt16(value) {
618
- this.writeInt8(value & 255);
619
- this.writeInt8(value >> 8);
891
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
620
892
  }
621
893
  writeInt32(value) {
622
- this.writeInt16(value & 65535);
623
- this.writeInt16(value >> 16);
894
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
895
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value >> 16);
624
896
  }
625
897
  writeInt64(value) {
626
898
  this.writeBigInt64(BigInt(value));
627
899
  }
628
900
  writeBigInt32(value) {
629
- this.writeInt16(Number(value & 0xffffn));
630
- this.writeInt16(Number(value >> 16n));
901
+ ConverterInt64[0] = value;
902
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
903
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
631
904
  }
632
905
  writeBigInt64(value) {
633
- this.writeInt32(Number(value & 0xffffffffn));
634
- this.writeInt32(Number(value >> 32n));
906
+ ConverterInt64[0] = value;
907
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
908
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
909
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
910
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
635
911
  }
636
912
  writeFloat32(value) {
637
913
  ConverterFloat[0] = value;
638
- this.writeInt8(Converter8[0]);
639
- this.writeInt8(Converter8[1]);
640
- this.writeInt8(Converter8[2]);
641
- this.writeInt8(Converter8[3]);
914
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
915
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
642
916
  }
643
917
  writeFloat64(value) {
644
918
  ConverterDouble[0] = value;
645
- this.writeInt8(Converter8[0]);
646
- this.writeInt8(Converter8[1]);
647
- this.writeInt8(Converter8[2]);
648
- this.writeInt8(Converter8[3]);
649
- this.writeInt8(Converter8[4]);
650
- this.writeInt8(Converter8[5]);
651
- this.writeInt8(Converter8[6]);
652
- this.writeInt8(Converter8[7]);
919
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
920
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
921
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
922
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
653
923
  }
654
924
  readBit(offset) {
655
925
  const ptr = Pointer.from(offset);
656
926
  return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
657
927
  }
658
928
  readInt2(offset) {
929
+ return this.readUint2(offset) << 30 >> 30;
930
+ }
931
+ readUint2(offset) {
659
932
  const ptr = Pointer.from(offset);
660
933
  return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
661
934
  }
662
935
  readInt4(offset) {
936
+ return this.readUint4(offset) << 28 >> 28;
937
+ }
938
+ readUint4(offset) {
663
939
  const ptr = Pointer.from(offset);
664
940
  return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3;
665
941
  }
666
942
  readInt8(offset) {
943
+ return this.readUint8(offset) << 24 >> 24;
944
+ }
945
+ readUint8(offset) {
667
946
  const ptr = Pointer.from(offset);
668
947
  return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
669
948
  }
670
949
  readInt16(offset) {
671
- const ptr = Pointer.from(offset);
672
- return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr) << 8;
950
+ return this.readUint16(offset) << 16 >> 16;
951
+ }
952
+ readUint16(offset) {
953
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead16_fn).call(this, Pointer.from(offset));
954
+ return ConverterUint16[0];
673
955
  }
674
956
  readInt32(offset) {
675
- return Number(this.readBigInt32(offset));
957
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
958
+ return ConverterInt32[0];
959
+ }
960
+ readUint32(offset) {
961
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
962
+ return ConverterUint32[0];
676
963
  }
677
964
  readInt64(offset) {
678
965
  return Number(this.readBigInt64(offset));
679
966
  }
967
+ readUint64(offset) {
968
+ return Number(this.readBigUint64(offset));
969
+ }
680
970
  readBigInt32(offset) {
681
- const ptr = Pointer.from(offset);
682
- 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;
971
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
972
+ return BigInt(ConverterInt32[0]);
973
+ }
974
+ readBigUint32(offset) {
975
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
976
+ return BigInt(ConverterUint32[0]);
683
977
  }
684
978
  readBigInt64(offset) {
685
- const ptr = Pointer.from(offset);
686
- 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;
979
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
980
+ return ConverterInt64[0];
981
+ }
982
+ readBigUint64(offset) {
983
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
984
+ return ConverterUint64[0];
687
985
  }
688
986
  readFloat32(offset) {
689
- const ptr = Pointer.from(offset);
690
- Converter8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
691
- Converter8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
692
- Converter8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
693
- Converter8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
987
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
694
988
  return ConverterFloat[0];
695
989
  }
696
990
  readFloat64(offset) {
697
- const ptr = Pointer.from(offset);
698
- Converter8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
699
- Converter8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
700
- Converter8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
701
- Converter8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
702
- Converter8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
703
- Converter8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
704
- Converter8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
705
- Converter8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
991
+ __privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
706
992
  return ConverterDouble[0];
707
993
  }
708
994
  toString() {
@@ -740,6 +1026,26 @@ readBit_fn = /* @__PURE__ */ __name(function(pointer) {
740
1026
  readByte_fn = /* @__PURE__ */ __name(function(ptr) {
741
1027
  return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 4 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 5 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 6 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 7;
742
1028
  }, "#readByte");
1029
+ bufferRead16_fn = /* @__PURE__ */ __name(function(ptr) {
1030
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1031
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1032
+ }, "#bufferRead16");
1033
+ bufferRead32_fn = /* @__PURE__ */ __name(function(ptr) {
1034
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1035
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1036
+ ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1037
+ ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1038
+ }, "#bufferRead32");
1039
+ bufferRead64_fn = /* @__PURE__ */ __name(function(ptr) {
1040
+ ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1041
+ ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1042
+ ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1043
+ ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1044
+ ConverterUint8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1045
+ ConverterUint8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1046
+ ConverterUint8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1047
+ ConverterUint8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
1048
+ }, "#bufferRead64");
743
1049
  writeBit_fn = /* @__PURE__ */ __name(function(value) {
744
1050
  if (__privateGet(this, _wordIndex) === this.maxLength) {
745
1051
  throw new RangeError(`The buffer is full`);
@@ -753,6 +1059,23 @@ writeBit_fn = /* @__PURE__ */ __name(function(value) {
753
1059
  __privateWrapper(this, _bitLength)._++;
754
1060
  if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordIndex)._++;
755
1061
  }, "#writeBit");
1062
+ bufferWrite16_fn = /* @__PURE__ */ __name(function(value) {
1063
+ const wordIndex = __privateGet(this, _wordIndex);
1064
+ const bitIndex = this.bitLength & 15;
1065
+ if (wordIndex + (bitIndex === 0 ? 0 : 1) === this.maxLength) {
1066
+ throw new RangeError(`The buffer is full`);
1067
+ }
1068
+ if (bitIndex === 0) {
1069
+ __privateGet(this, _buffer)[wordIndex] = value;
1070
+ } else {
1071
+ value &= 65535;
1072
+ __privateGet(this, _buffer)[wordIndex] |= value << bitIndex;
1073
+ __privateGet(this, _buffer)[wordIndex + 1] = value >> 16 - bitIndex;
1074
+ }
1075
+ __privateSet(this, _bitLength, __privateGet(this, _bitLength) + 16);
1076
+ __privateWrapper(this, _wordIndex)._++;
1077
+ __privateWrapper(this, _wordLength)._++;
1078
+ }, "#bufferWrite16");
756
1079
  __name(_UnalignedUint16Array, "UnalignedUint16Array");
757
1080
  var UnalignedUint16Array = _UnalignedUint16Array;
758
1081
 
@@ -867,9 +1190,29 @@ _schemas = new WeakMap();
867
1190
  __name(_SchemaStore, "SchemaStore");
868
1191
  var SchemaStore = _SchemaStore;
869
1192
 
1193
+ // src/lib/utilities.ts
1194
+ function toUTF16(buffer) {
1195
+ let result = "";
1196
+ for (const value of new Uint16Array(buffer.buffer)) {
1197
+ result += String.fromCharCode(value);
1198
+ }
1199
+ return result;
1200
+ }
1201
+ __name(toUTF16, "toUTF16");
1202
+ function fromUTF16(buffer) {
1203
+ const result = new Uint16Array(buffer.length);
1204
+ for (let i = 0; i < buffer.length; i++) {
1205
+ result[i] = buffer.charCodeAt(i);
1206
+ }
1207
+ return result;
1208
+ }
1209
+ __name(fromUTF16, "fromUTF16");
1210
+
870
1211
  exports.ArrayType = ArrayType;
871
1212
  exports.BigInt32Type = BigInt32Type;
872
1213
  exports.BigInt64Type = BigInt64Type;
1214
+ exports.BigUint32Type = BigUint32Type;
1215
+ exports.BigUint64Type = BigUint64Type;
873
1216
  exports.BitType = BitType;
874
1217
  exports.BooleanType = BooleanType;
875
1218
  exports.FixedLengthArrayType = FixedLengthArrayType;
@@ -886,6 +1229,15 @@ exports.Schema = Schema;
886
1229
  exports.SchemaStore = SchemaStore;
887
1230
  exports.SnowflakeType = SnowflakeType;
888
1231
  exports.StringType = StringType;
1232
+ exports.Uint16Type = Uint16Type;
1233
+ exports.Uint2Type = Uint2Type;
1234
+ exports.Uint32Type = Uint32Type;
1235
+ exports.Uint4Type = Uint4Type;
1236
+ exports.Uint64Type = Uint64Type;
1237
+ exports.Uint8Type = Uint8Type;
889
1238
  exports.UnalignedUint16Array = UnalignedUint16Array;
1239
+ exports.fromUTF16 = fromUTF16;
1240
+ exports.t = t;
1241
+ exports.toUTF16 = toUTF16;
890
1242
  //# sourceMappingURL=index.cjs.map
891
1243
  //# sourceMappingURL=index.cjs.map