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