@synnaxlabs/x 0.15.1 → 0.15.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@synnaxlabs/x",
3
3
  "private": false,
4
- "version": "0.15.1",
4
+ "version": "0.15.2",
5
5
  "type": "module",
6
6
  "description": "Common Utilities for Synnax Labs",
7
7
  "repository": "https://github.com/synnaxlabs/synnax/tree/main/x/go",
@@ -26,9 +26,9 @@
26
26
  "eslint": "^8.55.0",
27
27
  "vite": "^5.1.2",
28
28
  "vitest": "^1.2.2",
29
+ "@synnaxlabs/tsconfig": "0.0.2",
29
30
  "@synnaxlabs/vite-plugin": "0.0.1",
30
- "eslint-config-synnaxlabs": "0.0.1",
31
- "@synnaxlabs/tsconfig": "0.0.2"
31
+ "eslint-config-synnaxlabs": "0.0.1"
32
32
  },
33
33
  "main": "dist/x.cjs",
34
34
  "module": "dist/x.js",
@@ -314,6 +314,15 @@ describe("TimeRange", () => {
314
314
  expect(tr.end.equals(new TimeStamp(1000))).toBeTruthy();
315
315
  });
316
316
 
317
+ test("construct from object", () => {
318
+ const tr = new TimeRange({
319
+ start: new TimeStamp(1000),
320
+ end: new TimeStamp(100000),
321
+ });
322
+ expect(tr.start.equals(new TimeStamp(1000))).toBeTruthy();
323
+ expect(tr.end.equals(new TimeStamp(100000))).toBeTruthy();
324
+ });
325
+
317
326
  test("span", () => {
318
327
  const tr = new TimeRange(new TimeStamp(0), new TimeStamp(1000));
319
328
  expect(tr.span.equals(TimeSpan.MICROSECOND)).toBeTruthy();
@@ -877,15 +877,24 @@ export class TimeRange implements Stringer {
877
877
  */
878
878
  end: TimeStamp;
879
879
 
880
+ constructor(tr: CrudeTimeRange);
881
+
882
+ constructor(start: CrudeTimeStamp, end: CrudeTimeStamp);
883
+
880
884
  /**
881
885
  * Creates a TimeRange from the given start and end TimeStamps.
882
886
  *
883
887
  * @param start - A TimeStamp representing the start of the range.
884
888
  * @param end - A TimeStamp representing the end of the range.
885
889
  */
886
- constructor(start: CrudeTimeStamp, end: CrudeTimeStamp) {
887
- this.start = new TimeStamp(start);
888
- this.end = new TimeStamp(end);
890
+ constructor(start: CrudeTimeStamp | CrudeTimeRange, end?: CrudeTimeStamp) {
891
+ if (typeof start === "object" && "start" in start) {
892
+ this.start = new TimeStamp(start.start);
893
+ this.end = new TimeStamp(start.end);
894
+ } else {
895
+ this.start = new TimeStamp(start);
896
+ this.end = new TimeStamp(end);
897
+ }
889
898
  }
890
899
 
891
900
  /** @returns The TimeSpan occupied by the TimeRange. */