@sapphire/string-store 1.1.0-next.7c2bed20 → 1.1.0-next.bedc937e
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.
- package/README.md +118 -26
- package/dist/cjs/index.cjs +394 -56
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +244 -37
- package/dist/esm/index.d.mts +244 -37
- package/dist/esm/index.mjs +384 -57
- package/dist/esm/index.mjs.map +1 -1
- package/dist/iife/index.global.js +394 -56
- package/dist/iife/index.global.js.map +1 -1
- package/package.json +5 -5
|
@@ -87,7 +87,7 @@ var SapphireStringStore = (function (exports) {
|
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
89
|
deserialize(buffer, pointer) {
|
|
90
|
-
const length = buffer.
|
|
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.
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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.
|
|
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,
|
|
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
|
|
579
|
-
var
|
|
580
|
-
var
|
|
581
|
-
var
|
|
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;
|
|
582
855
|
var _UnalignedUint16Array = class _UnalignedUint16Array {
|
|
583
856
|
constructor(maxLength) {
|
|
584
857
|
__privateAdd(this, _UnalignedUint16Array_instances);
|
|
@@ -636,74 +909,90 @@ var SapphireStringStore = (function (exports) {
|
|
|
636
909
|
}
|
|
637
910
|
writeFloat32(value) {
|
|
638
911
|
ConverterFloat[0] = value;
|
|
639
|
-
this.writeInt8(
|
|
640
|
-
this.writeInt8(
|
|
641
|
-
this.writeInt8(
|
|
642
|
-
this.writeInt8(
|
|
912
|
+
this.writeInt8(ConverterUint8[0]);
|
|
913
|
+
this.writeInt8(ConverterUint8[1]);
|
|
914
|
+
this.writeInt8(ConverterUint8[2]);
|
|
915
|
+
this.writeInt8(ConverterUint8[3]);
|
|
643
916
|
}
|
|
644
917
|
writeFloat64(value) {
|
|
645
918
|
ConverterDouble[0] = value;
|
|
646
|
-
this.writeInt8(
|
|
647
|
-
this.writeInt8(
|
|
648
|
-
this.writeInt8(
|
|
649
|
-
this.writeInt8(
|
|
650
|
-
this.writeInt8(
|
|
651
|
-
this.writeInt8(
|
|
652
|
-
this.writeInt8(
|
|
653
|
-
this.writeInt8(
|
|
919
|
+
this.writeInt8(ConverterUint8[0]);
|
|
920
|
+
this.writeInt8(ConverterUint8[1]);
|
|
921
|
+
this.writeInt8(ConverterUint8[2]);
|
|
922
|
+
this.writeInt8(ConverterUint8[3]);
|
|
923
|
+
this.writeInt8(ConverterUint8[4]);
|
|
924
|
+
this.writeInt8(ConverterUint8[5]);
|
|
925
|
+
this.writeInt8(ConverterUint8[6]);
|
|
926
|
+
this.writeInt8(ConverterUint8[7]);
|
|
654
927
|
}
|
|
655
928
|
readBit(offset) {
|
|
656
929
|
const ptr = Pointer.from(offset);
|
|
657
930
|
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
|
|
658
931
|
}
|
|
659
932
|
readInt2(offset) {
|
|
933
|
+
return this.readUint2(offset) << 30 >> 30;
|
|
934
|
+
}
|
|
935
|
+
readUint2(offset) {
|
|
660
936
|
const ptr = Pointer.from(offset);
|
|
661
937
|
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
|
|
662
938
|
}
|
|
663
939
|
readInt4(offset) {
|
|
940
|
+
return this.readUint4(offset) << 28 >> 28;
|
|
941
|
+
}
|
|
942
|
+
readUint4(offset) {
|
|
664
943
|
const ptr = Pointer.from(offset);
|
|
665
944
|
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
945
|
}
|
|
667
946
|
readInt8(offset) {
|
|
947
|
+
return this.readUint8(offset) << 24 >> 24;
|
|
948
|
+
}
|
|
949
|
+
readUint8(offset) {
|
|
668
950
|
const ptr = Pointer.from(offset);
|
|
669
951
|
return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
670
952
|
}
|
|
671
953
|
readInt16(offset) {
|
|
672
|
-
|
|
673
|
-
|
|
954
|
+
return this.readUint16(offset) << 16 >> 16;
|
|
955
|
+
}
|
|
956
|
+
readUint16(offset) {
|
|
957
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead16_fn).call(this, Pointer.from(offset));
|
|
958
|
+
return ConverterUint16[0];
|
|
674
959
|
}
|
|
675
960
|
readInt32(offset) {
|
|
676
|
-
|
|
961
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
962
|
+
return ConverterInt32[0];
|
|
963
|
+
}
|
|
964
|
+
readUint32(offset) {
|
|
965
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
966
|
+
return ConverterUint32[0];
|
|
677
967
|
}
|
|
678
968
|
readInt64(offset) {
|
|
679
969
|
return Number(this.readBigInt64(offset));
|
|
680
970
|
}
|
|
971
|
+
readUint64(offset) {
|
|
972
|
+
return Number(this.readBigUint64(offset));
|
|
973
|
+
}
|
|
681
974
|
readBigInt32(offset) {
|
|
682
|
-
|
|
683
|
-
return BigInt(
|
|
975
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
976
|
+
return BigInt(ConverterInt32[0]);
|
|
977
|
+
}
|
|
978
|
+
readBigUint32(offset) {
|
|
979
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
980
|
+
return BigInt(ConverterUint32[0]);
|
|
684
981
|
}
|
|
685
982
|
readBigInt64(offset) {
|
|
686
|
-
|
|
687
|
-
return
|
|
983
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
984
|
+
return ConverterInt64[0];
|
|
985
|
+
}
|
|
986
|
+
readBigUint64(offset) {
|
|
987
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
988
|
+
return ConverterUint64[0];
|
|
688
989
|
}
|
|
689
990
|
readFloat32(offset) {
|
|
690
|
-
|
|
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);
|
|
991
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
695
992
|
return ConverterFloat[0];
|
|
696
993
|
}
|
|
697
994
|
readFloat64(offset) {
|
|
698
|
-
|
|
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);
|
|
995
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
707
996
|
return ConverterDouble[0];
|
|
708
997
|
}
|
|
709
998
|
toString() {
|
|
@@ -741,6 +1030,26 @@ var SapphireStringStore = (function (exports) {
|
|
|
741
1030
|
readByte_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
742
1031
|
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
1032
|
}, "#readByte");
|
|
1033
|
+
bufferRead16_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
|
+
}, "#bufferRead16");
|
|
1037
|
+
bufferRead32_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
1038
|
+
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1039
|
+
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1040
|
+
ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1041
|
+
ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1042
|
+
}, "#bufferRead32");
|
|
1043
|
+
bufferRead64_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
1044
|
+
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1045
|
+
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1046
|
+
ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1047
|
+
ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1048
|
+
ConverterUint8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1049
|
+
ConverterUint8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1050
|
+
ConverterUint8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1051
|
+
ConverterUint8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1052
|
+
}, "#bufferRead64");
|
|
744
1053
|
writeBit_fn = /* @__PURE__ */ __name(function(value) {
|
|
745
1054
|
if (__privateGet(this, _wordIndex) === this.maxLength) {
|
|
746
1055
|
throw new RangeError(`The buffer is full`);
|
|
@@ -868,9 +1177,29 @@ var SapphireStringStore = (function (exports) {
|
|
|
868
1177
|
__name(_SchemaStore, "SchemaStore");
|
|
869
1178
|
var SchemaStore = _SchemaStore;
|
|
870
1179
|
|
|
1180
|
+
// src/lib/utilities.ts
|
|
1181
|
+
function toUTF16(buffer) {
|
|
1182
|
+
let result = "";
|
|
1183
|
+
for (const value of new Uint16Array(buffer.buffer)) {
|
|
1184
|
+
result += String.fromCharCode(value);
|
|
1185
|
+
}
|
|
1186
|
+
return result;
|
|
1187
|
+
}
|
|
1188
|
+
__name(toUTF16, "toUTF16");
|
|
1189
|
+
function fromUTF16(buffer) {
|
|
1190
|
+
const result = new Uint16Array(buffer.length);
|
|
1191
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
1192
|
+
result[i] = buffer.charCodeAt(i);
|
|
1193
|
+
}
|
|
1194
|
+
return result;
|
|
1195
|
+
}
|
|
1196
|
+
__name(fromUTF16, "fromUTF16");
|
|
1197
|
+
|
|
871
1198
|
exports.ArrayType = ArrayType;
|
|
872
1199
|
exports.BigInt32Type = BigInt32Type;
|
|
873
1200
|
exports.BigInt64Type = BigInt64Type;
|
|
1201
|
+
exports.BigUint32Type = BigUint32Type;
|
|
1202
|
+
exports.BigUint64Type = BigUint64Type;
|
|
874
1203
|
exports.BitType = BitType;
|
|
875
1204
|
exports.BooleanType = BooleanType;
|
|
876
1205
|
exports.FixedLengthArrayType = FixedLengthArrayType;
|
|
@@ -887,7 +1216,16 @@ var SapphireStringStore = (function (exports) {
|
|
|
887
1216
|
exports.SchemaStore = SchemaStore;
|
|
888
1217
|
exports.SnowflakeType = SnowflakeType;
|
|
889
1218
|
exports.StringType = StringType;
|
|
1219
|
+
exports.Uint16Type = Uint16Type;
|
|
1220
|
+
exports.Uint2Type = Uint2Type;
|
|
1221
|
+
exports.Uint32Type = Uint32Type;
|
|
1222
|
+
exports.Uint4Type = Uint4Type;
|
|
1223
|
+
exports.Uint64Type = Uint64Type;
|
|
1224
|
+
exports.Uint8Type = Uint8Type;
|
|
890
1225
|
exports.UnalignedUint16Array = UnalignedUint16Array;
|
|
1226
|
+
exports.fromUTF16 = fromUTF16;
|
|
1227
|
+
exports.t = t;
|
|
1228
|
+
exports.toUTF16 = toUTF16;
|
|
891
1229
|
|
|
892
1230
|
return exports;
|
|
893
1231
|
|