@synnaxlabs/x 0.31.0 → 0.33.0
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/.turbo/turbo-build.log +24 -24
- package/dist/binary.cjs +1 -1
- package/dist/binary.js +1 -1
- package/dist/bounds-CCueigU3.js +171 -0
- package/dist/bounds-Cudf5M4H.cjs +1 -0
- package/dist/bounds.cjs +1 -1
- package/dist/bounds.js +1 -1
- package/dist/box-CZVdKCOc.cjs +1 -0
- package/dist/box-hAkmDC3K.js +201 -0
- package/dist/box.cjs +1 -1
- package/dist/box.js +1 -1
- package/dist/caseconv.cjs +1 -1
- package/dist/caseconv.js +1 -1
- package/dist/index-By0n2R_b.cjs +1 -0
- package/dist/{index-DgaYJC35.cjs → index-DQZfhLnw.cjs} +1 -1
- package/dist/{index-Duv1uH08.js → index-q_1Jz5rY.js} +5 -5
- package/dist/{index-B5THJ1eb.js → index-zsix_qnl.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +212 -178
- package/dist/{location-DjcaXEps.js → location-B5rSnQP3.js} +1 -1
- package/dist/{location-gPB1RtfA.cjs → location-YGxhLPDy.cjs} +1 -1
- package/dist/location.cjs +1 -1
- package/dist/location.js +1 -1
- package/dist/{position-DkON65EZ.js → position-BZOTg74V.js} +2 -2
- package/dist/{position-C71OiHiw.cjs → position-CjNCcq8X.cjs} +1 -1
- package/dist/position.cjs +1 -1
- package/dist/position.js +1 -1
- package/dist/{scale-COPgp55a.cjs → scale-BvbW9p2C.cjs} +1 -1
- package/dist/{scale-qw6vRO4s.js → scale-C7_4I3pa.js} +3 -3
- package/dist/scale.cjs +1 -1
- package/dist/scale.js +1 -1
- package/dist/series-BId9slhU.cjs +11 -0
- package/dist/{series-B5eA90Ci.js → series-CZw97Bq2.js} +619 -456
- package/dist/spatial.cjs +1 -1
- package/dist/spatial.js +5 -5
- package/dist/src/caseconv/caseconv.d.ts.map +1 -1
- package/dist/src/deep/path.d.ts +1 -1
- package/dist/src/deep/path.d.ts.map +1 -1
- package/dist/src/id/id.d.ts +1 -2
- package/dist/src/id/id.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/math/math.d.ts +26 -6
- package/dist/src/math/math.d.ts.map +1 -1
- package/dist/src/math/math.spec.d.ts +2 -0
- package/dist/src/math/math.spec.d.ts.map +1 -0
- package/dist/src/migrate/migrate.d.ts +4 -1
- package/dist/src/migrate/migrate.d.ts.map +1 -1
- package/dist/src/record.d.ts +4 -0
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/spatial/bounds/bounds.d.ts +204 -2
- package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
- package/dist/src/spatial/box/box.d.ts +4 -4
- package/dist/src/spatial/box/box.d.ts.map +1 -1
- package/dist/src/strings/index.d.ts +2 -0
- package/dist/src/strings/index.d.ts.map +1 -0
- package/dist/src/strings/strings.d.ts +32 -0
- package/dist/src/strings/strings.d.ts.map +1 -0
- package/dist/src/strings/strings.spec.d.ts +2 -0
- package/dist/src/strings/strings.spec.d.ts.map +1 -0
- package/dist/src/telem/series.d.ts +35 -10
- package/dist/src/telem/series.d.ts.map +1 -1
- package/dist/src/telem/telem.d.ts +12 -10
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/telem.cjs +1 -1
- package/dist/telem.js +1 -1
- package/package.json +9 -9
- package/src/caseconv/caseconv.ts +1 -0
- package/src/deep/path.ts +1 -1
- package/src/id/id.ts +2 -2
- package/src/index.ts +1 -0
- package/src/math/math.spec.ts +149 -0
- package/src/math/math.ts +60 -9
- package/src/migrate/migrate.ts +23 -4
- package/src/record.ts +5 -0
- package/src/spatial/bounds/bounds.spec.ts +135 -270
- package/src/spatial/bounds/bounds.ts +290 -25
- package/src/spatial/box/box.ts +9 -5
- package/src/strings/index.ts +10 -0
- package/src/strings/strings.spec.ts +68 -0
- package/src/strings/strings.ts +87 -0
- package/src/telem/series.spec.ts +235 -0
- package/src/telem/series.ts +271 -52
- package/src/telem/telem.spec.ts +22 -0
- package/src/telem/telem.ts +44 -20
- package/src/zodutil/zodutil.spec.ts +5 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/bounds-CpboA0q6.js +0 -127
- package/dist/bounds-ZZc1c-_Z.cjs +0 -1
- package/dist/box-BQID-0jO.cjs +0 -1
- package/dist/box-xRqO6NvI.js +0 -202
- package/dist/index-xk130iQA.cjs +0 -1
- package/dist/series-CJ65b1Uz.cjs +0 -11
package/src/telem/series.spec.ts
CHANGED
|
@@ -274,6 +274,19 @@ describe("Series", () => {
|
|
|
274
274
|
});
|
|
275
275
|
});
|
|
276
276
|
|
|
277
|
+
describe("atAlignment", () => {
|
|
278
|
+
it("should return the value at a particular alignment", () => {
|
|
279
|
+
const series = new Series({
|
|
280
|
+
data: new Float32Array([1, 2, 3]),
|
|
281
|
+
dataType: DataType.FLOAT32,
|
|
282
|
+
alignment: 1n,
|
|
283
|
+
});
|
|
284
|
+
expect(series.atAlignment(1n)).toEqual(1);
|
|
285
|
+
expect(series.atAlignment(2n)).toEqual(2);
|
|
286
|
+
expect(series.atAlignment(3n)).toEqual(3);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
277
290
|
describe("slice", () => {
|
|
278
291
|
it("should slice a lazy array", () => {
|
|
279
292
|
const a = new Series({
|
|
@@ -354,6 +367,7 @@ describe("Series", () => {
|
|
|
354
367
|
expect(series.write(writeTwo)).toEqual(2);
|
|
355
368
|
expect(series.length).toEqual(3);
|
|
356
369
|
});
|
|
370
|
+
|
|
357
371
|
it("should recompute cached max and min correctly", () => {
|
|
358
372
|
const series = Series.alloc({ capacity: 10, dataType: DataType.FLOAT32 });
|
|
359
373
|
series.enrich();
|
|
@@ -362,6 +376,7 @@ describe("Series", () => {
|
|
|
362
376
|
expect(series.max).toEqual(3);
|
|
363
377
|
expect(series.min).toEqual(2);
|
|
364
378
|
});
|
|
379
|
+
|
|
365
380
|
it("should correctly adjust the sample offset of a written array", () => {
|
|
366
381
|
const series = Series.alloc({
|
|
367
382
|
capacity: 2,
|
|
@@ -501,12 +516,14 @@ describe("Series", () => {
|
|
|
501
516
|
const outStrings = s.toStrings();
|
|
502
517
|
expect(outStrings).toEqual(["apple", "banana", "carrot"]);
|
|
503
518
|
});
|
|
519
|
+
|
|
504
520
|
it("should throw an error if the series is not of type string", () => {
|
|
505
521
|
const s = new Series({ data: new Float32Array([1, 2, 3]) });
|
|
506
522
|
expect(() => {
|
|
507
523
|
s.toStrings();
|
|
508
524
|
}).toThrow();
|
|
509
525
|
});
|
|
526
|
+
|
|
510
527
|
it("should not throw an error if the series is of type UUID", () => {
|
|
511
528
|
const s = new Series({
|
|
512
529
|
data: new Uint8Array([1, 2, 3]),
|
|
@@ -516,11 +533,50 @@ describe("Series", () => {
|
|
|
516
533
|
s.toStrings();
|
|
517
534
|
}).not.toThrow();
|
|
518
535
|
});
|
|
536
|
+
|
|
519
537
|
it("should return an array of length 0 if the series is empty", () => {
|
|
520
538
|
const s = new Series({ data: new Float32Array([]), dataType: DataType.STRING });
|
|
521
539
|
const outStrings = s.toStrings();
|
|
522
540
|
expect(outStrings).toEqual([]);
|
|
523
541
|
});
|
|
542
|
+
|
|
543
|
+
it("should allow allocation of a particular byte capacity", () => {
|
|
544
|
+
const s = Series.alloc({ capacity: 10, dataType: DataType.STRING });
|
|
545
|
+
expect(s.byteCapacity).toEqual(Size.bytes(10));
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
it("should allow a caller to write to the series", () => {
|
|
549
|
+
const s = Series.alloc({ capacity: 10, dataType: DataType.STRING });
|
|
550
|
+
const writeOne = new Series({ data: ["apple"] });
|
|
551
|
+
const written = s.write(writeOne);
|
|
552
|
+
expect(written).toEqual(1);
|
|
553
|
+
expect(s.length).toEqual(1);
|
|
554
|
+
expect(s.at(0)).toEqual("apple");
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
it("should allow a caller to write to the series multiple times", () => {
|
|
558
|
+
const s = Series.alloc({ capacity: 100, dataType: DataType.STRING });
|
|
559
|
+
const writeOne = new Series({ data: ["apple"] });
|
|
560
|
+
const writeTwo = new Series({ data: ["banana", "carrot"] });
|
|
561
|
+
const written = s.write(writeOne);
|
|
562
|
+
expect(written).toEqual(1);
|
|
563
|
+
const writtenTwo = s.write(writeTwo);
|
|
564
|
+
expect(writtenTwo).toEqual(2);
|
|
565
|
+
expect(s.length).toEqual(3);
|
|
566
|
+
expect(s.at(0)).toEqual("apple");
|
|
567
|
+
expect(s.at(1)).toEqual("banana");
|
|
568
|
+
expect(s.at(2)).toEqual("carrot");
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
it("should prevent the caller from writing past the series capacity", () => {
|
|
572
|
+
const s = Series.alloc({ capacity: 10, dataType: DataType.STRING });
|
|
573
|
+
const writeOne = new Series({ data: ["apple"] });
|
|
574
|
+
const writeTwo = new Series({ data: ["banana", "carrot"] });
|
|
575
|
+
const written = s.write(writeOne);
|
|
576
|
+
expect(written).toEqual(1);
|
|
577
|
+
const writtenTwo = s.write(writeTwo);
|
|
578
|
+
expect(writtenTwo).toEqual(0);
|
|
579
|
+
});
|
|
524
580
|
});
|
|
525
581
|
|
|
526
582
|
describe("JSON series", () => {
|
|
@@ -662,6 +718,50 @@ describe("Series", () => {
|
|
|
662
718
|
expect(s.length).toEqual(0);
|
|
663
719
|
});
|
|
664
720
|
});
|
|
721
|
+
|
|
722
|
+
describe("sub", () => {
|
|
723
|
+
it("should return a sub-series backed by the same buffer", () => {
|
|
724
|
+
const arr = new Float32Array([1, 2, 3, 4, 5]);
|
|
725
|
+
const v2 = arr.subarray(1, 4);
|
|
726
|
+
expect(v2.buffer).toBe(arr.buffer);
|
|
727
|
+
const s1 = new Series(arr);
|
|
728
|
+
expect(s1.buffer).toBe(arr.buffer);
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
describe("subIter", () => {
|
|
733
|
+
it("should return an iterator over a sub-series", () => {
|
|
734
|
+
const s = new Series(new Float32Array([1, 2, 3, 4, 5]));
|
|
735
|
+
const iter = s.subIterator(1, 4);
|
|
736
|
+
expect(iter.next().value).toEqual(2);
|
|
737
|
+
expect(iter.next().value).toEqual(3);
|
|
738
|
+
expect(iter.next().value).toEqual(4);
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
describe("subIterAlignment", () => {
|
|
743
|
+
it("should return an iterator over a sub-series", () => {
|
|
744
|
+
const s = new Series({
|
|
745
|
+
data: new Float32Array([1, 2, 3, 4, 5]),
|
|
746
|
+
alignment: 2n,
|
|
747
|
+
});
|
|
748
|
+
const iter = s.subAlignmentIterator(3n, 5n);
|
|
749
|
+
expect(iter.next().value).toEqual(2);
|
|
750
|
+
expect(iter.next().value).toEqual(3);
|
|
751
|
+
expect(iter.next().done).toBeTruthy();
|
|
752
|
+
});
|
|
753
|
+
it("should clamp the bounds to the alignment", () => {
|
|
754
|
+
const s = new Series({
|
|
755
|
+
data: new Float32Array([1, 2, 3, 4, 5]),
|
|
756
|
+
alignment: 2n,
|
|
757
|
+
});
|
|
758
|
+
const iter = s.subAlignmentIterator(1n, 5n);
|
|
759
|
+
expect(iter.next().value).toEqual(1);
|
|
760
|
+
expect(iter.next().value).toEqual(2);
|
|
761
|
+
expect(iter.next().value).toEqual(3);
|
|
762
|
+
expect(iter.next().done).toBeTruthy();
|
|
763
|
+
});
|
|
764
|
+
});
|
|
665
765
|
});
|
|
666
766
|
|
|
667
767
|
describe("MultiSeries", () => {
|
|
@@ -673,6 +773,7 @@ describe("MultiSeries", () => {
|
|
|
673
773
|
expect(multi.length).toEqual(6);
|
|
674
774
|
});
|
|
675
775
|
});
|
|
776
|
+
|
|
676
777
|
describe("at", () => {
|
|
677
778
|
it("should correctly return the value at a particular index", () => {
|
|
678
779
|
const a = new Series(new Float32Array([1, 2, 3]));
|
|
@@ -698,6 +799,140 @@ describe("MultiSeries", () => {
|
|
|
698
799
|
});
|
|
699
800
|
});
|
|
700
801
|
|
|
802
|
+
describe("atAlignment", () => {
|
|
803
|
+
it("should correctly return the value at a particular alignment", () => {
|
|
804
|
+
const a = new Series({
|
|
805
|
+
data: new Float32Array([1, 2, 3]),
|
|
806
|
+
alignment: 1n,
|
|
807
|
+
});
|
|
808
|
+
const b = new Series({
|
|
809
|
+
data: new Float32Array([4, 5, 6]),
|
|
810
|
+
alignment: 5n,
|
|
811
|
+
});
|
|
812
|
+
const multi = new MultiSeries([a, b]);
|
|
813
|
+
expect(multi.atAlignment(1n)).toEqual(1);
|
|
814
|
+
expect(multi.atAlignment(2n)).toEqual(2);
|
|
815
|
+
expect(multi.atAlignment(3n)).toEqual(3);
|
|
816
|
+
expect(multi.atAlignment(5n)).toEqual(4);
|
|
817
|
+
expect(multi.atAlignment(6n)).toEqual(5);
|
|
818
|
+
expect(multi.atAlignment(7n)).toEqual(6);
|
|
819
|
+
});
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
describe("subIterator", () => {
|
|
823
|
+
it("should return an iterator over a sub-series", () => {
|
|
824
|
+
const a = new Series(new Float32Array([1, 2, 3, 4, 5]));
|
|
825
|
+
const b = new Series(new Float32Array([6, 7, 8, 9, 10]));
|
|
826
|
+
const multi = new MultiSeries([a, b]);
|
|
827
|
+
const iter = multi.subIterator(1, 8);
|
|
828
|
+
expect(iter.next().value).toEqual(2);
|
|
829
|
+
expect(iter.next().value).toEqual(3);
|
|
830
|
+
expect(iter.next().value).toEqual(4);
|
|
831
|
+
expect(iter.next().value).toEqual(5);
|
|
832
|
+
expect(iter.next().value).toEqual(6);
|
|
833
|
+
expect(iter.next().value).toEqual(7);
|
|
834
|
+
expect(iter.next().value).toEqual(8);
|
|
835
|
+
expect(iter.next().done).toBeTruthy();
|
|
836
|
+
});
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
describe("subAlignmentIterator", () => {
|
|
840
|
+
it("should return an iterator over a sub-series", () => {
|
|
841
|
+
const a = new Series({
|
|
842
|
+
data: new Float32Array([1, 2, 3, 4, 5]),
|
|
843
|
+
alignment: 2n,
|
|
844
|
+
});
|
|
845
|
+
const b = new Series({
|
|
846
|
+
data: new Float32Array([6, 7, 8, 9, 10]),
|
|
847
|
+
alignment: 8n,
|
|
848
|
+
});
|
|
849
|
+
const multi = new MultiSeries([a, b]);
|
|
850
|
+
const iter = multi.subAlignmentIterator(3n, 9n);
|
|
851
|
+
expect(iter.next().value).toEqual(2);
|
|
852
|
+
expect(iter.next().value).toEqual(3);
|
|
853
|
+
expect(iter.next().value).toEqual(4);
|
|
854
|
+
expect(iter.next().value).toEqual(5);
|
|
855
|
+
expect(iter.next().value).toEqual(6);
|
|
856
|
+
expect(iter.next().done).toBeTruthy();
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
it("Should work correctly when starting at an alignment before the first series", () => {
|
|
860
|
+
const a = new Series({
|
|
861
|
+
data: new Float32Array([1, 2, 3, 4, 5]),
|
|
862
|
+
alignment: 2n,
|
|
863
|
+
});
|
|
864
|
+
const b = new Series({
|
|
865
|
+
data: new Float32Array([6, 7, 8, 9, 10]),
|
|
866
|
+
alignment: 8n,
|
|
867
|
+
});
|
|
868
|
+
const multi = new MultiSeries([a, b]);
|
|
869
|
+
const iter = multi.subAlignmentIterator(1n, 9n);
|
|
870
|
+
expect(iter.next().value).toEqual(1);
|
|
871
|
+
expect(iter.next().value).toEqual(2);
|
|
872
|
+
expect(iter.next().value).toEqual(3);
|
|
873
|
+
expect(iter.next().value).toEqual(4);
|
|
874
|
+
expect(iter.next().value).toEqual(5);
|
|
875
|
+
expect(iter.next().value).toEqual(6);
|
|
876
|
+
expect(iter.next().done).toBeTruthy();
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
it("should work correctly when staring at an alignment equal to the upper bound of the first series", () => {
|
|
880
|
+
const a = new Series({
|
|
881
|
+
data: new Float32Array([1, 2, 3, 4, 5]),
|
|
882
|
+
alignment: 2n,
|
|
883
|
+
});
|
|
884
|
+
const b = new Series({
|
|
885
|
+
data: new Float32Array([6, 7, 8, 9, 10]),
|
|
886
|
+
alignment: 8n,
|
|
887
|
+
});
|
|
888
|
+
console.log(a.alignmentBounds.upper);
|
|
889
|
+
const multi = new MultiSeries([a, b]);
|
|
890
|
+
const iter = multi.subAlignmentIterator(7n, 10n);
|
|
891
|
+
expect(iter.next().value).toEqual(6);
|
|
892
|
+
expect(iter.next().value).toEqual(7);
|
|
893
|
+
expect(iter.next().done).toBeTruthy();
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
it("should work correctly when the starting alignment is between two series", () => {
|
|
897
|
+
const a = new Series({
|
|
898
|
+
data: new Float32Array([1, 2, 3, 4, 5]),
|
|
899
|
+
alignment: 2n,
|
|
900
|
+
});
|
|
901
|
+
const b = new Series({
|
|
902
|
+
data: new Float32Array([6, 7, 8, 9, 10]),
|
|
903
|
+
alignment: 10n,
|
|
904
|
+
});
|
|
905
|
+
const multi = new MultiSeries([a, b]);
|
|
906
|
+
const iter = multi.subAlignmentIterator(7n, 12n);
|
|
907
|
+
expect(iter.next().value).toEqual(6);
|
|
908
|
+
expect(iter.next().value).toEqual(7);
|
|
909
|
+
expect(iter.next().done).toBeTruthy();
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
it("Should work correctly when ending at an alignment after the last series", () => {
|
|
913
|
+
const a = new Series({
|
|
914
|
+
data: new Float32Array([1, 2, 3, 4, 5]),
|
|
915
|
+
alignment: 2n,
|
|
916
|
+
});
|
|
917
|
+
const b = new Series({
|
|
918
|
+
data: new Float32Array([6, 7, 8, 9, 10]),
|
|
919
|
+
alignment: 8n,
|
|
920
|
+
});
|
|
921
|
+
const multi = new MultiSeries([a, b]);
|
|
922
|
+
const iter = multi.subAlignmentIterator(3n, 20n);
|
|
923
|
+
expect(iter.next().value).toEqual(2);
|
|
924
|
+
expect(iter.next().value).toEqual(3);
|
|
925
|
+
expect(iter.next().value).toEqual(4);
|
|
926
|
+
expect(iter.next().value).toEqual(5);
|
|
927
|
+
expect(iter.next().value).toEqual(6);
|
|
928
|
+
expect(iter.next().value).toEqual(7);
|
|
929
|
+
expect(iter.next().value).toEqual(8);
|
|
930
|
+
expect(iter.next().value).toEqual(9);
|
|
931
|
+
expect(iter.next().value).toEqual(10);
|
|
932
|
+
expect(iter.next().done).toBeTruthy();
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
|
|
701
936
|
describe("array construction", () => {
|
|
702
937
|
it("should correctly construct a JS array from a multi-series", () => {
|
|
703
938
|
const a = new Series(new Float32Array([1, 2, 3]));
|