@sapphire/string-store 1.1.0-next.7c2bed20 → 1.1.0-next.98befbf8
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 +131 -39
- package/dist/cjs/index.cjs +416 -64
- 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 +406 -65
- package/dist/esm/index.mjs.map +1 -1
- package/dist/iife/index.global.js +416 -64
- package/dist/iife/index.global.js.map +1 -1
- package/package.json +7 -7
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, bufferWrite16_fn;
|
|
579
852
|
var _UnalignedUint16Array = class _UnalignedUint16Array {
|
|
580
853
|
constructor(maxLength) {
|
|
581
854
|
__privateAdd(this, _UnalignedUint16Array_instances);
|
|
@@ -613,94 +886,107 @@ var _UnalignedUint16Array = class _UnalignedUint16Array {
|
|
|
613
886
|
this.writeInt4(value >> 4);
|
|
614
887
|
}
|
|
615
888
|
writeInt16(value) {
|
|
616
|
-
this.
|
|
617
|
-
this.writeInt8(value >> 8);
|
|
889
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
|
|
618
890
|
}
|
|
619
891
|
writeInt32(value) {
|
|
620
|
-
this.
|
|
621
|
-
this.
|
|
892
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
|
|
893
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value >> 16);
|
|
622
894
|
}
|
|
623
895
|
writeInt64(value) {
|
|
624
896
|
this.writeBigInt64(BigInt(value));
|
|
625
897
|
}
|
|
626
898
|
writeBigInt32(value) {
|
|
627
|
-
|
|
628
|
-
this.
|
|
899
|
+
ConverterInt64[0] = value;
|
|
900
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
901
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
629
902
|
}
|
|
630
903
|
writeBigInt64(value) {
|
|
631
|
-
|
|
632
|
-
this.
|
|
904
|
+
ConverterInt64[0] = value;
|
|
905
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
906
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
907
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
|
|
908
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
|
|
633
909
|
}
|
|
634
910
|
writeFloat32(value) {
|
|
635
911
|
ConverterFloat[0] = value;
|
|
636
|
-
this.
|
|
637
|
-
this.
|
|
638
|
-
this.writeInt8(Converter8[2]);
|
|
639
|
-
this.writeInt8(Converter8[3]);
|
|
912
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
913
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
640
914
|
}
|
|
641
915
|
writeFloat64(value) {
|
|
642
916
|
ConverterDouble[0] = value;
|
|
643
|
-
this.
|
|
644
|
-
this.
|
|
645
|
-
this.
|
|
646
|
-
this.
|
|
647
|
-
this.writeInt8(Converter8[4]);
|
|
648
|
-
this.writeInt8(Converter8[5]);
|
|
649
|
-
this.writeInt8(Converter8[6]);
|
|
650
|
-
this.writeInt8(Converter8[7]);
|
|
917
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
918
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
919
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
|
|
920
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
|
|
651
921
|
}
|
|
652
922
|
readBit(offset) {
|
|
653
923
|
const ptr = Pointer.from(offset);
|
|
654
924
|
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
|
|
655
925
|
}
|
|
656
926
|
readInt2(offset) {
|
|
927
|
+
return this.readUint2(offset) << 30 >> 30;
|
|
928
|
+
}
|
|
929
|
+
readUint2(offset) {
|
|
657
930
|
const ptr = Pointer.from(offset);
|
|
658
931
|
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
|
|
659
932
|
}
|
|
660
933
|
readInt4(offset) {
|
|
934
|
+
return this.readUint4(offset) << 28 >> 28;
|
|
935
|
+
}
|
|
936
|
+
readUint4(offset) {
|
|
661
937
|
const ptr = Pointer.from(offset);
|
|
662
938
|
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
939
|
}
|
|
664
940
|
readInt8(offset) {
|
|
941
|
+
return this.readUint8(offset) << 24 >> 24;
|
|
942
|
+
}
|
|
943
|
+
readUint8(offset) {
|
|
665
944
|
const ptr = Pointer.from(offset);
|
|
666
945
|
return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
667
946
|
}
|
|
668
947
|
readInt16(offset) {
|
|
669
|
-
|
|
670
|
-
|
|
948
|
+
return this.readUint16(offset) << 16 >> 16;
|
|
949
|
+
}
|
|
950
|
+
readUint16(offset) {
|
|
951
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead16_fn).call(this, Pointer.from(offset));
|
|
952
|
+
return ConverterUint16[0];
|
|
671
953
|
}
|
|
672
954
|
readInt32(offset) {
|
|
673
|
-
|
|
955
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
956
|
+
return ConverterInt32[0];
|
|
957
|
+
}
|
|
958
|
+
readUint32(offset) {
|
|
959
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
960
|
+
return ConverterUint32[0];
|
|
674
961
|
}
|
|
675
962
|
readInt64(offset) {
|
|
676
963
|
return Number(this.readBigInt64(offset));
|
|
677
964
|
}
|
|
965
|
+
readUint64(offset) {
|
|
966
|
+
return Number(this.readBigUint64(offset));
|
|
967
|
+
}
|
|
678
968
|
readBigInt32(offset) {
|
|
679
|
-
|
|
680
|
-
return BigInt(
|
|
969
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
970
|
+
return BigInt(ConverterInt32[0]);
|
|
971
|
+
}
|
|
972
|
+
readBigUint32(offset) {
|
|
973
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
974
|
+
return BigInt(ConverterUint32[0]);
|
|
681
975
|
}
|
|
682
976
|
readBigInt64(offset) {
|
|
683
|
-
|
|
684
|
-
return
|
|
977
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
978
|
+
return ConverterInt64[0];
|
|
979
|
+
}
|
|
980
|
+
readBigUint64(offset) {
|
|
981
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
982
|
+
return ConverterUint64[0];
|
|
685
983
|
}
|
|
686
984
|
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);
|
|
985
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
692
986
|
return ConverterFloat[0];
|
|
693
987
|
}
|
|
694
988
|
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);
|
|
989
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
704
990
|
return ConverterDouble[0];
|
|
705
991
|
}
|
|
706
992
|
toString() {
|
|
@@ -738,6 +1024,26 @@ readBit_fn = /* @__PURE__ */ __name(function(pointer) {
|
|
|
738
1024
|
readByte_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
739
1025
|
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
1026
|
}, "#readByte");
|
|
1027
|
+
bufferRead16_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
1028
|
+
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1029
|
+
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1030
|
+
}, "#bufferRead16");
|
|
1031
|
+
bufferRead32_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
1032
|
+
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1033
|
+
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1034
|
+
ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1035
|
+
ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1036
|
+
}, "#bufferRead32");
|
|
1037
|
+
bufferRead64_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
|
+
ConverterUint8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1043
|
+
ConverterUint8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1044
|
+
ConverterUint8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1045
|
+
ConverterUint8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
1046
|
+
}, "#bufferRead64");
|
|
741
1047
|
writeBit_fn = /* @__PURE__ */ __name(function(value) {
|
|
742
1048
|
if (__privateGet(this, _wordIndex) === this.maxLength) {
|
|
743
1049
|
throw new RangeError(`The buffer is full`);
|
|
@@ -751,6 +1057,23 @@ writeBit_fn = /* @__PURE__ */ __name(function(value) {
|
|
|
751
1057
|
__privateWrapper(this, _bitLength)._++;
|
|
752
1058
|
if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordIndex)._++;
|
|
753
1059
|
}, "#writeBit");
|
|
1060
|
+
bufferWrite16_fn = /* @__PURE__ */ __name(function(value) {
|
|
1061
|
+
const wordIndex = __privateGet(this, _wordIndex);
|
|
1062
|
+
const bitIndex = this.bitLength & 15;
|
|
1063
|
+
if (wordIndex + (bitIndex === 0 ? 0 : 1) === this.maxLength) {
|
|
1064
|
+
throw new RangeError(`The buffer is full`);
|
|
1065
|
+
}
|
|
1066
|
+
if (bitIndex === 0) {
|
|
1067
|
+
__privateGet(this, _buffer)[wordIndex] = value;
|
|
1068
|
+
} else {
|
|
1069
|
+
value &= 65535;
|
|
1070
|
+
__privateGet(this, _buffer)[wordIndex] |= value << bitIndex;
|
|
1071
|
+
__privateGet(this, _buffer)[wordIndex + 1] = value >> 16 - bitIndex;
|
|
1072
|
+
}
|
|
1073
|
+
__privateSet(this, _bitLength, __privateGet(this, _bitLength) + 16);
|
|
1074
|
+
__privateWrapper(this, _wordIndex)._++;
|
|
1075
|
+
__privateWrapper(this, _wordLength)._++;
|
|
1076
|
+
}, "#bufferWrite16");
|
|
754
1077
|
__name(_UnalignedUint16Array, "UnalignedUint16Array");
|
|
755
1078
|
var UnalignedUint16Array = _UnalignedUint16Array;
|
|
756
1079
|
|
|
@@ -865,6 +1188,24 @@ _schemas = new WeakMap();
|
|
|
865
1188
|
__name(_SchemaStore, "SchemaStore");
|
|
866
1189
|
var SchemaStore = _SchemaStore;
|
|
867
1190
|
|
|
868
|
-
|
|
1191
|
+
// src/lib/utilities.ts
|
|
1192
|
+
function toUTF16(buffer) {
|
|
1193
|
+
let result = "";
|
|
1194
|
+
for (const value of new Uint16Array(buffer.buffer)) {
|
|
1195
|
+
result += String.fromCharCode(value);
|
|
1196
|
+
}
|
|
1197
|
+
return result;
|
|
1198
|
+
}
|
|
1199
|
+
__name(toUTF16, "toUTF16");
|
|
1200
|
+
function fromUTF16(buffer) {
|
|
1201
|
+
const result = new Uint16Array(buffer.length);
|
|
1202
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
1203
|
+
result[i] = buffer.charCodeAt(i);
|
|
1204
|
+
}
|
|
1205
|
+
return result;
|
|
1206
|
+
}
|
|
1207
|
+
__name(fromUTF16, "fromUTF16");
|
|
1208
|
+
|
|
1209
|
+
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
1210
|
//# sourceMappingURL=index.mjs.map
|
|
870
1211
|
//# sourceMappingURL=index.mjs.map
|