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