@synnaxlabs/x 0.44.2 → 0.44.4
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 +35 -39
- package/dist/base-BLNViP3D.cjs +1 -0
- package/dist/{base-DFq0vvGn.js → base-BORMP3mH.js} +14 -11
- package/dist/bounds-BQqppNFf.js +186 -0
- package/dist/bounds-BXbqBINt.cjs +1 -0
- package/dist/bounds.cjs +1 -1
- package/dist/bounds.js +1 -1
- package/dist/{box-CO_2_DGG.js → box-DRH5SOaY.js} +67 -73
- package/dist/box-qgxWXNhm.cjs +1 -0
- package/dist/box.cjs +1 -1
- package/dist/box.js +1 -1
- package/dist/deep.cjs +1 -1
- package/dist/deep.js +1 -1
- package/dist/{dimensions-CRgergMS.js → dimensions-RaRkesPq.js} +1 -1
- package/dist/{dimensions-D2QGoNXO.cjs → dimensions-qY12pyfC.cjs} +1 -1
- package/dist/dimensions.cjs +1 -1
- package/dist/dimensions.js +1 -1
- package/dist/direction-DKdfJwj7.js +19 -0
- package/dist/direction-XCdrc4is.cjs +1 -0
- package/dist/direction.cjs +1 -1
- package/dist/direction.js +1 -1
- package/dist/{external-Birv9jaY.js → external-BM_NS5yM.js} +6 -6
- package/dist/external-E3ErJeeM.cjs +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +244 -240
- package/dist/{location-Ar5y2DX2.js → location-CGLioInQ.js} +16 -21
- package/dist/location-DJ_K4SlP.cjs +1 -0
- package/dist/location.cjs +1 -1
- package/dist/location.js +1 -1
- package/dist/{path-DVFrKaNI.js → path-Blh4wJuA.js} +24 -21
- package/dist/path-CPSfCjde.cjs +1 -0
- package/dist/record-BwjIgrpU.cjs +1 -0
- package/dist/record-tSFQKmdG.js +19 -0
- package/dist/record.cjs +1 -1
- package/dist/record.js +1 -1
- package/dist/{scale-C6qKDbRb.cjs → scale-76Azh2EE.cjs} +1 -1
- package/dist/{scale-EWNUk-bn.js → scale-BhIvACdB.js} +4 -4
- package/dist/scale.cjs +1 -1
- package/dist/scale.js +1 -1
- package/dist/{series-EA1uaEDj.js → series-kgnLXSDr.js} +622 -489
- package/dist/series-tAhThbnz.cjs +6 -0
- package/dist/{spatial-DGpZ2sO3.cjs → spatial-BsGadoUr.cjs} +1 -1
- package/dist/{spatial-BSWPzMkK.js → spatial-QY891r0E.js} +1 -1
- package/dist/spatial.cjs +1 -1
- package/dist/spatial.js +14 -16
- package/dist/src/breaker/breaker.d.ts +2 -1
- package/dist/src/breaker/breaker.d.ts.map +1 -1
- package/dist/src/deep/path.d.ts.map +1 -1
- package/dist/src/id/id.d.ts +3 -1
- package/dist/src/id/id.d.ts.map +1 -1
- package/dist/src/math/math.d.ts +2 -1
- package/dist/src/math/math.d.ts.map +1 -1
- package/dist/src/record/record.d.ts +18 -0
- package/dist/src/record/record.d.ts.map +1 -1
- package/dist/src/spatial/base.d.ts +12 -0
- package/dist/src/spatial/base.d.ts.map +1 -1
- package/dist/src/spatial/direction/direction.d.ts +5 -1
- package/dist/src/spatial/direction/direction.d.ts.map +1 -1
- package/dist/src/spatial/external.d.ts +0 -1
- package/dist/src/spatial/external.d.ts.map +1 -1
- package/dist/src/spatial/xy/xy.d.ts +3 -0
- package/dist/src/spatial/xy/xy.d.ts.map +1 -1
- package/dist/src/status/status.d.ts +1 -0
- package/dist/src/status/status.d.ts.map +1 -1
- package/dist/src/strings/strings.d.ts +1 -1
- package/dist/src/strings/strings.d.ts.map +1 -1
- package/dist/src/telem/series.d.ts +7 -0
- package/dist/src/telem/series.d.ts.map +1 -1
- package/dist/src/telem/telem.d.ts +86 -1
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/src/zod/util.d.ts.map +1 -1
- package/dist/telem.cjs +1 -1
- package/dist/telem.js +1 -1
- package/dist/xy-BKIJiLu_.cjs +1 -0
- package/dist/{xy-C_-hb3Q2.js → xy-CBuhMaIo.js} +41 -31
- package/dist/xy.cjs +1 -1
- package/dist/xy.js +1 -1
- package/dist/zod.cjs +1 -1
- package/dist/zod.js +1 -1
- package/package.json +3 -8
- package/src/breaker/breaker.ts +4 -0
- package/src/deep/path.spec.ts +14 -0
- package/src/deep/path.ts +9 -2
- package/src/id/id.ts +8 -4
- package/src/math/math.spec.ts +20 -0
- package/src/math/math.ts +32 -29
- package/src/record/record.spec.ts +31 -0
- package/src/record/record.ts +23 -0
- package/src/spatial/base.ts +4 -0
- package/src/spatial/bounds/bounds.ts +1 -1
- package/src/spatial/direction/direction.spec.ts +35 -1
- package/src/spatial/direction/direction.ts +12 -0
- package/src/spatial/external.ts +0 -1
- package/src/spatial/xy/xy.spec.ts +124 -7
- package/src/spatial/xy/xy.ts +15 -2
- package/src/status/status.ts +11 -0
- package/src/strings/strings.spec.ts +3 -0
- package/src/strings/strings.ts +2 -1
- package/src/telem/series.spec.ts +543 -2
- package/src/telem/series.ts +28 -9
- package/src/telem/telem.spec.ts +606 -0
- package/src/telem/telem.ts +143 -5
- package/src/zod/util.ts +5 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +0 -1
- package/dist/base-BAM2mqCy.cjs +0 -1
- package/dist/bounds-D6e9xoHt.cjs +0 -1
- package/dist/bounds-Dj9nG39I.js +0 -174
- package/dist/box-Cxki783Y.cjs +0 -1
- package/dist/direction-386XDm2w.cjs +0 -1
- package/dist/direction-8etxfKaR.js +0 -17
- package/dist/external-DsmsSN1Y.cjs +0 -1
- package/dist/location-DZi8ftXp.cjs +0 -1
- package/dist/path-BeMr8xWN.cjs +0 -1
- package/dist/position-DSy2hONH.cjs +0 -1
- package/dist/position-PQ6op54I.js +0 -85
- package/dist/position.cjs +0 -1
- package/dist/position.js +0 -4
- package/dist/record-CAcQ5PNX.js +0 -14
- package/dist/record-YvCh7bzB.cjs +0 -1
- package/dist/series-CcA_WjbJ.cjs +0 -6
- package/dist/src/spatial/position/index.d.ts +0 -2
- package/dist/src/spatial/position/index.d.ts.map +0 -1
- package/dist/src/spatial/position/position.d.ts +0 -20
- package/dist/src/spatial/position/position.d.ts.map +0 -1
- package/dist/src/spatial/position/position.spec.d.ts +0 -2
- package/dist/src/spatial/position/position.spec.d.ts.map +0 -1
- package/dist/xy-CUE3QDNn.cjs +0 -1
- package/src/spatial/position/index.ts +0 -10
- package/src/spatial/position/position.spec.ts +0 -211
- package/src/spatial/position/position.ts +0 -157
|
@@ -1,64 +1,64 @@
|
|
|
1
1
|
import { z as o } from "zod";
|
|
2
|
-
import { J as
|
|
3
|
-
import { s as
|
|
4
|
-
import { V as
|
|
5
|
-
import { m as
|
|
6
|
-
import "./box-
|
|
7
|
-
import "./dimensions-
|
|
8
|
-
import "./base-
|
|
9
|
-
import "./location-
|
|
10
|
-
import "./scale-
|
|
11
|
-
import "./xy-
|
|
12
|
-
let
|
|
2
|
+
import { J as $ } from "./index-B5l_quQn.js";
|
|
3
|
+
import { s as nt } from "./index-D2xcvEO5.js";
|
|
4
|
+
import { V as C, n as rt } from "./index-CBMHFqs4.js";
|
|
5
|
+
import { a as L, s as S, m as N, d as p, c as x, e as k, f as R, g as it, t as at, h as ut } from "./bounds-BQqppNFf.js";
|
|
6
|
+
import "./box-DRH5SOaY.js";
|
|
7
|
+
import "./dimensions-RaRkesPq.js";
|
|
8
|
+
import "./base-BORMP3mH.js";
|
|
9
|
+
import "./location-CGLioInQ.js";
|
|
10
|
+
import "./scale-BhIvACdB.js";
|
|
11
|
+
import "./xy-CBuhMaIo.js";
|
|
12
|
+
let W = (a, t = 21) => (e = t) => {
|
|
13
13
|
let s = "", u = e | 0;
|
|
14
14
|
for (; u--; )
|
|
15
|
-
s +=
|
|
15
|
+
s += a[Math.random() * a.length | 0];
|
|
16
16
|
return s;
|
|
17
17
|
};
|
|
18
|
-
const
|
|
18
|
+
const H = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ot = `0123456789${H}`, K = 11, lt = W(H, 1), ft = W(ot, K - 1), X = () => `${lt()}${ft()}`, kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
19
19
|
__proto__: null,
|
|
20
|
-
LENGTH:
|
|
21
|
-
create:
|
|
22
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
20
|
+
LENGTH: K,
|
|
21
|
+
create: X
|
|
22
|
+
}, Symbol.toStringTag, { value: "Module" })), D = (a, t) => (e) => e instanceof t || typeof e == "object" && e !== null && "discriminator" in e && e.discriminator === a, Gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
23
23
|
__proto__: null,
|
|
24
|
-
createMatcher:
|
|
25
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
24
|
+
createMatcher: D
|
|
25
|
+
}, Symbol.toStringTag, { value: "Module" })), ht = o.enum(["static", "dynamic"]), ct = o.union([
|
|
26
26
|
o.tuple([o.int()]),
|
|
27
27
|
o.tuple([o.int(), o.int().min(1).max(12)]),
|
|
28
28
|
o.tuple([o.int(), o.int().min(1).max(12), o.int().min(1).max(31)])
|
|
29
|
-
]),
|
|
30
|
-
const e = new
|
|
29
|
+
]), Q = (a, t) => {
|
|
30
|
+
const e = new r(t);
|
|
31
31
|
if (![
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
i.DAY,
|
|
33
|
+
i.HOUR,
|
|
34
|
+
i.MINUTE,
|
|
35
|
+
i.SECOND,
|
|
36
|
+
i.MILLISECOND,
|
|
37
|
+
i.MICROSECOND,
|
|
38
|
+
i.NANOSECOND
|
|
39
39
|
].some((u) => u.equals(e)))
|
|
40
40
|
throw new Error(
|
|
41
41
|
"Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
|
|
42
42
|
);
|
|
43
|
-
const s =
|
|
44
|
-
return
|
|
43
|
+
const s = a.valueOf() % e.valueOf();
|
|
44
|
+
return a instanceof r ? new r(s) : new i(s);
|
|
45
45
|
};
|
|
46
|
-
class
|
|
46
|
+
class r extends C {
|
|
47
47
|
constructor(t, e = "UTC") {
|
|
48
|
-
if (t == null) super(
|
|
48
|
+
if (t == null) super(r.now().valueOf());
|
|
49
49
|
else if (t instanceof Date)
|
|
50
|
-
super(BigInt(t.getTime()) *
|
|
50
|
+
super(BigInt(t.getTime()) * r.MILLISECOND.valueOf());
|
|
51
51
|
else if (typeof t == "string")
|
|
52
|
-
super(
|
|
53
|
-
else if (Array.isArray(t)) super(
|
|
52
|
+
super(r.parseDateTimeString(t, e).valueOf());
|
|
53
|
+
else if (Array.isArray(t)) super(r.parseDate(t));
|
|
54
54
|
else {
|
|
55
55
|
let s = 0n;
|
|
56
|
-
t instanceof Number && (t = t.valueOf()), e === "local" && (s =
|
|
56
|
+
t instanceof Number && (t = t.valueOf()), e === "local" && (s = r.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = Math.trunc(t) : (isNaN(t) && (t = 0), t === 1 / 0 ? t = r.MAX : t = r.MIN)), super(BigInt(t.valueOf()) + s);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
static parseDate([t = 1970, e = 1, s = 1]) {
|
|
60
60
|
const u = new Date(t, e - 1, s, 0, 0, 0, 0);
|
|
61
|
-
return new
|
|
61
|
+
return new r(BigInt(u.getTime()) * r.MILLISECOND.valueOf()).truncate(r.DAY).valueOf();
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* @returns the primitive value of the TimeStamp. Overrides standard JS valueOf()
|
|
@@ -68,18 +68,18 @@ class n extends M {
|
|
|
68
68
|
return this.value;
|
|
69
69
|
}
|
|
70
70
|
static parseTimeString(t, e = "UTC") {
|
|
71
|
-
const [s, u,
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
let
|
|
75
|
-
return e === "local" && (
|
|
71
|
+
const [s, u, l] = t.split(":");
|
|
72
|
+
let h = "00", U = "00";
|
|
73
|
+
l != null && ([h, U] = l.split("."));
|
|
74
|
+
let y = r.hours(parseInt(s ?? "00")).add(r.minutes(parseInt(u ?? "00"))).add(r.seconds(parseInt(h ?? "00"))).add(r.milliseconds(parseInt(U ?? "00")));
|
|
75
|
+
return e === "local" && (y = y.add(r.utcOffset)), y.valueOf();
|
|
76
76
|
}
|
|
77
77
|
static parseDateTimeString(t, e = "UTC") {
|
|
78
78
|
if (!t.includes("/") && !t.includes("-"))
|
|
79
|
-
return
|
|
79
|
+
return r.parseTimeString(t, e);
|
|
80
80
|
const s = new Date(t);
|
|
81
|
-
return t.includes(":") || s.setUTCHours(0, 0, 0, 0), new
|
|
82
|
-
BigInt(s.getTime()) *
|
|
81
|
+
return t.includes(":") || s.setUTCHours(0, 0, 0, 0), new r(
|
|
82
|
+
BigInt(s.getTime()) * r.MILLISECOND.valueOf(),
|
|
83
83
|
e
|
|
84
84
|
).valueOf();
|
|
85
85
|
}
|
|
@@ -111,7 +111,7 @@ class n extends M {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
toISOString(t = "UTC") {
|
|
114
|
-
return t === "UTC" ? this.date().toISOString() : this.sub(
|
|
114
|
+
return t === "UTC" ? this.date().toISOString() : this.sub(r.utcOffset).date().toISOString();
|
|
115
115
|
}
|
|
116
116
|
timeString(t = !1, e = "UTC") {
|
|
117
117
|
const s = this.toISOString(e);
|
|
@@ -123,8 +123,8 @@ class n extends M {
|
|
|
123
123
|
}
|
|
124
124
|
/** @returns The UTC offset for the time zone of the machine. */
|
|
125
125
|
static get utcOffset() {
|
|
126
|
-
return new
|
|
127
|
-
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) *
|
|
126
|
+
return new i(
|
|
127
|
+
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * r.MINUTE.valueOf()
|
|
128
128
|
);
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
@@ -133,7 +133,7 @@ class n extends M {
|
|
|
133
133
|
* @param other - The other timestamp.
|
|
134
134
|
*/
|
|
135
135
|
static since(t) {
|
|
136
|
-
return new
|
|
136
|
+
return new r().span(t);
|
|
137
137
|
}
|
|
138
138
|
/** @returns A JavaScript Date object representing the TimeStamp. */
|
|
139
139
|
date() {
|
|
@@ -146,7 +146,7 @@ class n extends M {
|
|
|
146
146
|
* @returns True if the TimeStamps are equal, false otherwise.
|
|
147
147
|
*/
|
|
148
148
|
equals(t) {
|
|
149
|
-
return this.valueOf() === new
|
|
149
|
+
return this.valueOf() === new r(t).valueOf();
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* Creates a TimeSpan representing the duration between the two timestamps.
|
|
@@ -166,7 +166,7 @@ class n extends M {
|
|
|
166
166
|
* valid, regardless of the TimeStamp order.
|
|
167
167
|
*/
|
|
168
168
|
range(t) {
|
|
169
|
-
return new
|
|
169
|
+
return new O(this, t).makeValid();
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Creates a TimeRange starting at the TimeStamp and spanning the given
|
|
@@ -195,7 +195,7 @@ class n extends M {
|
|
|
195
195
|
* otherwise.
|
|
196
196
|
*/
|
|
197
197
|
after(t) {
|
|
198
|
-
return this.valueOf() > new
|
|
198
|
+
return this.valueOf() > new r(t).valueOf();
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* Checks if the TimeStamp is after or equal to the given TimeStamp.
|
|
@@ -205,7 +205,7 @@ class n extends M {
|
|
|
205
205
|
* false otherwise.
|
|
206
206
|
*/
|
|
207
207
|
afterEq(t) {
|
|
208
|
-
return this.valueOf() >= new
|
|
208
|
+
return this.valueOf() >= new r(t).valueOf();
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
211
211
|
* Checks if the TimeStamp is before the given TimeStamp.
|
|
@@ -215,7 +215,7 @@ class n extends M {
|
|
|
215
215
|
* otherwise.
|
|
216
216
|
*/
|
|
217
217
|
before(t) {
|
|
218
|
-
return this.valueOf() < new
|
|
218
|
+
return this.valueOf() < new r(t).valueOf();
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* Checks if TimeStamp is before or equal to the current timestamp.
|
|
@@ -225,7 +225,7 @@ class n extends M {
|
|
|
225
225
|
* false otherwise.
|
|
226
226
|
*/
|
|
227
227
|
beforeEq(t) {
|
|
228
|
-
return this.valueOf() <= new
|
|
228
|
+
return this.valueOf() <= new r(t).valueOf();
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
231
|
* Adds a TimeSpan to the TimeStamp.
|
|
@@ -235,7 +235,7 @@ class n extends M {
|
|
|
235
235
|
* TimeSpan.
|
|
236
236
|
*/
|
|
237
237
|
add(t) {
|
|
238
|
-
return new
|
|
238
|
+
return new r(L(this.valueOf(), new i(t).valueOf()));
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
241
|
* Subtracts a TimeSpan from the TimeStamp.
|
|
@@ -245,43 +245,43 @@ class n extends M {
|
|
|
245
245
|
* TimeSpan.
|
|
246
246
|
*/
|
|
247
247
|
sub(t) {
|
|
248
|
-
return new
|
|
248
|
+
return new r(S(this.valueOf(), new i(t).valueOf()));
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
251
|
* @returns the floating point number of hours since the unix epoch to the timestamp
|
|
252
252
|
* value.
|
|
253
253
|
*/
|
|
254
254
|
get hours() {
|
|
255
|
-
return Number(this.valueOf()) / Number(
|
|
255
|
+
return Number(this.valueOf()) / Number(i.HOUR.valueOf());
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
258
|
* @returns the floating point number of minutes since the unix epoch to the timestamp
|
|
259
259
|
* value.
|
|
260
260
|
*/
|
|
261
261
|
get minutes() {
|
|
262
|
-
return Number(this.valueOf()) / Number(
|
|
262
|
+
return Number(this.valueOf()) / Number(i.MINUTE.valueOf());
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
265
265
|
* @returns the floating point number of days since the unix epoch to the timestamp
|
|
266
266
|
* value.
|
|
267
267
|
*/
|
|
268
268
|
get days() {
|
|
269
|
-
return Number(this.valueOf()) / Number(
|
|
269
|
+
return Number(this.valueOf()) / Number(i.DAY.valueOf());
|
|
270
270
|
}
|
|
271
271
|
/**
|
|
272
272
|
* @returns the floating point number of seconds since the unix epoch to the timestamp
|
|
273
273
|
* value.
|
|
274
274
|
*/
|
|
275
275
|
get seconds() {
|
|
276
|
-
return Number(this.valueOf()) / Number(
|
|
276
|
+
return Number(this.valueOf()) / Number(i.SECOND.valueOf());
|
|
277
277
|
}
|
|
278
278
|
/** @returns the floating point number of milliseconds since the unix epoch. */
|
|
279
279
|
get milliseconds() {
|
|
280
|
-
return Number(this.valueOf()) / Number(
|
|
280
|
+
return Number(this.valueOf()) / Number(r.MILLISECOND.valueOf());
|
|
281
281
|
}
|
|
282
282
|
/** @returns the floating point number of microseconds since the unix epoch. */
|
|
283
283
|
get microseconds() {
|
|
284
|
-
return Number(this.valueOf()) / Number(
|
|
284
|
+
return Number(this.valueOf()) / Number(r.MICROSECOND.valueOf());
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
287
287
|
* @returns the floating point number of nanoseconds since the unix epoch.
|
|
@@ -301,7 +301,7 @@ class n extends M {
|
|
|
301
301
|
*/
|
|
302
302
|
setYear(t) {
|
|
303
303
|
const e = this.date();
|
|
304
|
-
return e.setUTCFullYear(t), new
|
|
304
|
+
return e.setUTCFullYear(t), new r(e);
|
|
305
305
|
}
|
|
306
306
|
/** @returns the integer month that the timestamp corresponds to with its year. */
|
|
307
307
|
get month() {
|
|
@@ -313,7 +313,7 @@ class n extends M {
|
|
|
313
313
|
*/
|
|
314
314
|
setMonth(t) {
|
|
315
315
|
const e = this.date();
|
|
316
|
-
return e.setUTCMonth(t), new
|
|
316
|
+
return e.setUTCMonth(t), new r(e);
|
|
317
317
|
}
|
|
318
318
|
/** @returns the integer day that the timestamp corresponds to within its month. */
|
|
319
319
|
get day() {
|
|
@@ -325,7 +325,7 @@ class n extends M {
|
|
|
325
325
|
*/
|
|
326
326
|
setDay(t) {
|
|
327
327
|
const e = this.date();
|
|
328
|
-
return e.setUTCDate(t), new
|
|
328
|
+
return e.setUTCDate(t), new r(e);
|
|
329
329
|
}
|
|
330
330
|
/**
|
|
331
331
|
* @returns the integer hour that the timestamp corresponds to within its day.
|
|
@@ -339,7 +339,7 @@ class n extends M {
|
|
|
339
339
|
*/
|
|
340
340
|
setHour(t) {
|
|
341
341
|
const e = this.date();
|
|
342
|
-
return e.setUTCHours(t), new
|
|
342
|
+
return e.setUTCHours(t), new r(e, "UTC");
|
|
343
343
|
}
|
|
344
344
|
/** @returns the integer minute that the timestamp corresponds to within its hour. */
|
|
345
345
|
get minute() {
|
|
@@ -351,7 +351,7 @@ class n extends M {
|
|
|
351
351
|
*/
|
|
352
352
|
setMinute(t) {
|
|
353
353
|
const e = this.date();
|
|
354
|
-
return e.setUTCMinutes(t), new
|
|
354
|
+
return e.setUTCMinutes(t), new r(e);
|
|
355
355
|
}
|
|
356
356
|
/**
|
|
357
357
|
* @returns the integer second that the timestamp corresponds to within its
|
|
@@ -366,7 +366,7 @@ class n extends M {
|
|
|
366
366
|
*/
|
|
367
367
|
setSecond(t) {
|
|
368
368
|
const e = this.date();
|
|
369
|
-
return e.setUTCSeconds(t), new
|
|
369
|
+
return e.setUTCSeconds(t), new r(e);
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
372
372
|
* @reutrns the integer millisecond that the timestamp corresponds to within
|
|
@@ -381,7 +381,7 @@ class n extends M {
|
|
|
381
381
|
*/
|
|
382
382
|
setMillisecond(t) {
|
|
383
383
|
const e = this.date();
|
|
384
|
-
return e.setUTCMilliseconds(t), new
|
|
384
|
+
return e.setUTCMilliseconds(t), new r(e);
|
|
385
385
|
}
|
|
386
386
|
/** @returns the time stamp formatted as an ISO string. */
|
|
387
387
|
toString() {
|
|
@@ -399,11 +399,11 @@ class n extends M {
|
|
|
399
399
|
* @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
|
|
400
400
|
*/
|
|
401
401
|
remainder(t) {
|
|
402
|
-
return
|
|
402
|
+
return Q(this, t);
|
|
403
403
|
}
|
|
404
404
|
/** @returns true if the day portion TimeStamp is today, false otherwise. */
|
|
405
405
|
get isToday() {
|
|
406
|
-
return this.truncate(
|
|
406
|
+
return this.truncate(i.DAY).equals(r.now().truncate(i.DAY));
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
409
409
|
* Truncates the TimeStamp to the nearest multiple of the given span.
|
|
@@ -420,7 +420,7 @@ class n extends M {
|
|
|
420
420
|
* JavaScript can do).
|
|
421
421
|
*/
|
|
422
422
|
static now() {
|
|
423
|
-
return new
|
|
423
|
+
return new r(/* @__PURE__ */ new Date());
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
426
|
* Finds the maximum timestamp among the provided timestamps.
|
|
@@ -429,9 +429,9 @@ class n extends M {
|
|
|
429
429
|
* @returns The maximum (latest) timestamp from the input.
|
|
430
430
|
*/
|
|
431
431
|
static max(...t) {
|
|
432
|
-
let e =
|
|
432
|
+
let e = r.MIN;
|
|
433
433
|
for (const s of t) {
|
|
434
|
-
const u = new
|
|
434
|
+
const u = new r(s);
|
|
435
435
|
u.after(e) && (e = u);
|
|
436
436
|
}
|
|
437
437
|
return e;
|
|
@@ -443,9 +443,9 @@ class n extends M {
|
|
|
443
443
|
* @returns The minimum (earliest) timestamp from the input.
|
|
444
444
|
*/
|
|
445
445
|
static min(...t) {
|
|
446
|
-
let e =
|
|
446
|
+
let e = r.MAX;
|
|
447
447
|
for (const s of t) {
|
|
448
|
-
const u = new
|
|
448
|
+
const u = new r(s);
|
|
449
449
|
u.before(e) && (e = u);
|
|
450
450
|
}
|
|
451
451
|
return e;
|
|
@@ -457,62 +457,62 @@ class n extends M {
|
|
|
457
457
|
* @returns A TimeStamp representing the given number of nanoseconds.
|
|
458
458
|
*/
|
|
459
459
|
static nanoseconds(t, e = "UTC") {
|
|
460
|
-
return new
|
|
460
|
+
return new r(t, e);
|
|
461
461
|
}
|
|
462
462
|
/** One nanosecond after the unix epoch */
|
|
463
|
-
static NANOSECOND =
|
|
463
|
+
static NANOSECOND = r.nanoseconds(1);
|
|
464
464
|
/** @returns a new TimeStamp n microseconds after the unix epoch */
|
|
465
465
|
static microseconds(t, e = "UTC") {
|
|
466
|
-
return
|
|
466
|
+
return r.nanoseconds(t * 1e3, e);
|
|
467
467
|
}
|
|
468
468
|
/** One microsecond after the unix epoch */
|
|
469
|
-
static MICROSECOND =
|
|
469
|
+
static MICROSECOND = r.microseconds(1);
|
|
470
470
|
/** @returns a new TimeStamp n milliseconds after the unix epoch */
|
|
471
471
|
static milliseconds(t, e = "UTC") {
|
|
472
|
-
return
|
|
472
|
+
return r.microseconds(t * 1e3, e);
|
|
473
473
|
}
|
|
474
474
|
/** One millisecond after the unix epoch */
|
|
475
|
-
static MILLISECOND =
|
|
475
|
+
static MILLISECOND = r.milliseconds(1);
|
|
476
476
|
/** @returns a new TimeStamp n seconds after the unix epoch */
|
|
477
477
|
static seconds(t, e = "UTC") {
|
|
478
|
-
return
|
|
478
|
+
return r.milliseconds(t * 1e3, e);
|
|
479
479
|
}
|
|
480
480
|
/** One second after the unix epoch */
|
|
481
|
-
static SECOND =
|
|
481
|
+
static SECOND = r.seconds(1);
|
|
482
482
|
/** @returns a new TimeStamp n minutes after the unix epoch */
|
|
483
483
|
static minutes(t, e = "UTC") {
|
|
484
|
-
return
|
|
484
|
+
return r.seconds(t * 60, e);
|
|
485
485
|
}
|
|
486
486
|
/** One minute after the unix epoch */
|
|
487
|
-
static MINUTE =
|
|
487
|
+
static MINUTE = r.minutes(1);
|
|
488
488
|
/** @returns a new TimeStamp n hours after the unix epoch */
|
|
489
489
|
static hours(t, e = "UTC") {
|
|
490
|
-
return
|
|
490
|
+
return r.minutes(t * 60, e);
|
|
491
491
|
}
|
|
492
492
|
/** One hour after the unix epoch */
|
|
493
|
-
static HOUR =
|
|
493
|
+
static HOUR = r.hours(1);
|
|
494
494
|
/** @returns a new TimeStamp n days after the unix epoch */
|
|
495
495
|
static days(t, e = "UTC") {
|
|
496
|
-
return
|
|
496
|
+
return r.hours(t * 24, e);
|
|
497
497
|
}
|
|
498
498
|
/** One day after the unix epoch */
|
|
499
|
-
static DAY =
|
|
499
|
+
static DAY = r.days(1);
|
|
500
500
|
/** The maximum possible value for a timestamp */
|
|
501
|
-
static MAX = new
|
|
501
|
+
static MAX = new r((1n << 63n) - 1n);
|
|
502
502
|
/** The minimum possible value for a timestamp */
|
|
503
|
-
static MIN = new
|
|
503
|
+
static MIN = new r(0);
|
|
504
504
|
/** The unix epoch */
|
|
505
|
-
static ZERO = new
|
|
505
|
+
static ZERO = new r(0);
|
|
506
506
|
/** A zod schema for validating timestamps */
|
|
507
507
|
static z = o.union([
|
|
508
|
-
o.instanceof(
|
|
509
|
-
o.object({ value: o.bigint() }).transform((t) => new
|
|
510
|
-
o.string().transform((t) => new
|
|
511
|
-
o.number().transform((t) => new
|
|
512
|
-
o.bigint().transform((t) => new
|
|
513
|
-
o.date().transform((t) => new
|
|
514
|
-
o.custom((t) => t instanceof
|
|
515
|
-
|
|
508
|
+
o.instanceof(r),
|
|
509
|
+
o.object({ value: o.bigint() }).transform((t) => new r(t.value)),
|
|
510
|
+
o.string().transform((t) => new r(BigInt(t))),
|
|
511
|
+
o.number().transform((t) => new r(t)),
|
|
512
|
+
o.bigint().transform((t) => new r(t)),
|
|
513
|
+
o.date().transform((t) => new r(t)),
|
|
514
|
+
o.custom((t) => t instanceof i).transform((t) => new r(t)),
|
|
515
|
+
ct.transform((t) => new r(t))
|
|
516
516
|
]);
|
|
517
517
|
/**
|
|
518
518
|
* Sorts two timestamps.
|
|
@@ -526,7 +526,7 @@ class n extends M {
|
|
|
526
526
|
return Number(t.valueOf() - e.valueOf());
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
class
|
|
529
|
+
class i extends C {
|
|
530
530
|
constructor(t) {
|
|
531
531
|
typeof t == "number" && (t = Math.trunc(t.valueOf())), super(BigInt(t.valueOf()));
|
|
532
532
|
}
|
|
@@ -537,7 +537,7 @@ class a extends M {
|
|
|
537
537
|
* @returns A TimeSpan representing the given number of seconds.
|
|
538
538
|
*/
|
|
539
539
|
static fromSeconds(t) {
|
|
540
|
-
return t instanceof
|
|
540
|
+
return t instanceof i ? t : t instanceof I ? t.period : t instanceof r ? new i(t) : ["number", "bigint"].includes(typeof t) ? i.seconds(t) : new i(t);
|
|
541
541
|
}
|
|
542
542
|
/**
|
|
543
543
|
* Creates a TimeSpan representing the given number of milliseconds.
|
|
@@ -546,7 +546,7 @@ class a extends M {
|
|
|
546
546
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
547
547
|
*/
|
|
548
548
|
static fromMilliseconds(t) {
|
|
549
|
-
return t instanceof
|
|
549
|
+
return t instanceof i ? t : t instanceof I ? t.period : t instanceof r ? new i(t) : ["number", "bigint"].includes(typeof t) ? i.milliseconds(t) : new i(t);
|
|
550
550
|
}
|
|
551
551
|
/**
|
|
552
552
|
* @returns the primitive value of the TimeSpan. Overrides standard JS valueOf()
|
|
@@ -562,7 +562,7 @@ class a extends M {
|
|
|
562
562
|
* @returns True if the TimeSpan is less than the other TimeSpan, false otherwise.
|
|
563
563
|
*/
|
|
564
564
|
lessThan(t) {
|
|
565
|
-
return this.valueOf() < new
|
|
565
|
+
return this.valueOf() < new i(t).valueOf();
|
|
566
566
|
}
|
|
567
567
|
/**
|
|
568
568
|
* Checks if the TimeSpan is greater than another TimeSpan.
|
|
@@ -571,7 +571,7 @@ class a extends M {
|
|
|
571
571
|
* @returns True if the TimeSpan is greater than the other TimeSpan, false otherwise.
|
|
572
572
|
*/
|
|
573
573
|
greaterThan(t) {
|
|
574
|
-
return this.valueOf() > new
|
|
574
|
+
return this.valueOf() > new i(t).valueOf();
|
|
575
575
|
}
|
|
576
576
|
/**
|
|
577
577
|
* Checks if the TimeSpan is less than or equal to another TimeSpan.
|
|
@@ -580,7 +580,7 @@ class a extends M {
|
|
|
580
580
|
* @returns True if the TimeSpan is less than or equal to the other TimeSpan, false otherwise.
|
|
581
581
|
*/
|
|
582
582
|
lessThanOrEqual(t) {
|
|
583
|
-
return this.valueOf() <= new
|
|
583
|
+
return this.valueOf() <= new i(t).valueOf();
|
|
584
584
|
}
|
|
585
585
|
/**
|
|
586
586
|
* Checks if the TimeSpan is greater than or equal to another TimeSpan.
|
|
@@ -589,7 +589,7 @@ class a extends M {
|
|
|
589
589
|
* @returns True if the TimeSpan is greater than or equal to the other TimeSpan, false otherwise.
|
|
590
590
|
*/
|
|
591
591
|
greaterThanOrEqual(t) {
|
|
592
|
-
return this.valueOf() >= new
|
|
592
|
+
return this.valueOf() >= new i(t).valueOf();
|
|
593
593
|
}
|
|
594
594
|
/**
|
|
595
595
|
* Calculates the remainder of the TimeSpan when divided by another TimeSpan.
|
|
@@ -598,7 +598,7 @@ class a extends M {
|
|
|
598
598
|
* @returns A new TimeSpan representing the remainder.
|
|
599
599
|
*/
|
|
600
600
|
remainder(t) {
|
|
601
|
-
return
|
|
601
|
+
return Q(this, t);
|
|
602
602
|
}
|
|
603
603
|
/**
|
|
604
604
|
* Truncates the TimeSpan to the nearest multiple of the given span.
|
|
@@ -607,7 +607,7 @@ class a extends M {
|
|
|
607
607
|
* @returns A new TimeSpan that is truncated to the nearest multiple of the given span.
|
|
608
608
|
*/
|
|
609
609
|
truncate(t) {
|
|
610
|
-
return new
|
|
610
|
+
return new i(
|
|
611
611
|
BigInt(Math.trunc(Number(this.valueOf() / t.valueOf()))) * t.valueOf()
|
|
612
612
|
);
|
|
613
613
|
}
|
|
@@ -617,9 +617,9 @@ class a extends M {
|
|
|
617
617
|
* @returns A string representation of the TimeSpan.
|
|
618
618
|
*/
|
|
619
619
|
toString() {
|
|
620
|
-
const t = this.truncate(
|
|
621
|
-
let
|
|
622
|
-
return
|
|
620
|
+
const t = this.truncate(i.DAY), e = this.truncate(i.HOUR), s = this.truncate(i.MINUTE), u = this.truncate(i.SECOND), l = this.truncate(i.MILLISECOND), h = this.truncate(i.MICROSECOND), U = this.truncate(i.NANOSECOND), y = t, g = e.sub(t), m = s.sub(e), b = u.sub(s), f = l.sub(u), A = h.sub(l), M = U.sub(h);
|
|
621
|
+
let E = "";
|
|
622
|
+
return y.isZero || (E += `${y.days}d `), g.isZero || (E += `${g.hours}h `), m.isZero || (E += `${m.minutes}m `), b.isZero || (E += `${b.seconds}s `), f.isZero || (E += `${f.milliseconds}ms `), A.isZero || (E += `${A.microseconds}µs `), M.isZero || (E += `${M.nanoseconds}ns`), E.trim();
|
|
623
623
|
}
|
|
624
624
|
/**
|
|
625
625
|
* Multiplies the TimeSpan by a scalar value.
|
|
@@ -628,31 +628,40 @@ class a extends M {
|
|
|
628
628
|
* @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
|
|
629
629
|
*/
|
|
630
630
|
mult(t) {
|
|
631
|
-
return new
|
|
631
|
+
return new i(N(this.valueOf(), t));
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Divides the TimeSpan by a scalar value.
|
|
635
|
+
*
|
|
636
|
+
* @param value - The scalar value to divide by.
|
|
637
|
+
* @returns A new TimeSpan that is this TimeSpan divided by the provided value.
|
|
638
|
+
*/
|
|
639
|
+
div(t) {
|
|
640
|
+
return new i(p(this.valueOf(), t));
|
|
632
641
|
}
|
|
633
642
|
/** @returns the decimal number of days in the TimeSpan. */
|
|
634
643
|
get days() {
|
|
635
|
-
return Number(this.valueOf()) / Number(
|
|
644
|
+
return Number(this.valueOf()) / Number(i.DAY.valueOf());
|
|
636
645
|
}
|
|
637
646
|
/** @returns the decimal number of hours in the TimeSpan. */
|
|
638
647
|
get hours() {
|
|
639
|
-
return Number(this.valueOf()) / Number(
|
|
648
|
+
return Number(this.valueOf()) / Number(i.HOUR.valueOf());
|
|
640
649
|
}
|
|
641
650
|
/** @returns the decimal number of minutes in the TimeSpan. */
|
|
642
651
|
get minutes() {
|
|
643
|
-
return Number(this.valueOf()) / Number(
|
|
652
|
+
return Number(this.valueOf()) / Number(i.MINUTE.valueOf());
|
|
644
653
|
}
|
|
645
654
|
/** @returns The number of seconds in the TimeSpan. */
|
|
646
655
|
get seconds() {
|
|
647
|
-
return Number(this.valueOf()) / Number(
|
|
656
|
+
return Number(this.valueOf()) / Number(i.SECOND.valueOf());
|
|
648
657
|
}
|
|
649
658
|
/** @returns The number of milliseconds in the TimeSpan. */
|
|
650
659
|
get milliseconds() {
|
|
651
|
-
return Number(this.valueOf()) / Number(
|
|
660
|
+
return Number(this.valueOf()) / Number(i.MILLISECOND.valueOf());
|
|
652
661
|
}
|
|
653
662
|
/** @returns The number of microseconds in the TimeSpan. */
|
|
654
663
|
get microseconds() {
|
|
655
|
-
return Number(this.valueOf()) / Number(
|
|
664
|
+
return Number(this.valueOf()) / Number(i.MICROSECOND.valueOf());
|
|
656
665
|
}
|
|
657
666
|
/** @returns The number of nanoseconds in the TimeSpan. */
|
|
658
667
|
get nanoseconds() {
|
|
@@ -672,7 +681,7 @@ class a extends M {
|
|
|
672
681
|
* @returns True if the TimeSpans are equal, false otherwise.
|
|
673
682
|
*/
|
|
674
683
|
equals(t) {
|
|
675
|
-
return this.valueOf() === new
|
|
684
|
+
return this.valueOf() === new i(t).valueOf();
|
|
676
685
|
}
|
|
677
686
|
/**
|
|
678
687
|
* Adds a TimeSpan to the TimeSpan.
|
|
@@ -680,7 +689,7 @@ class a extends M {
|
|
|
680
689
|
* @returns A new TimeSpan representing the sum of the two TimeSpans.
|
|
681
690
|
*/
|
|
682
691
|
add(t) {
|
|
683
|
-
return new
|
|
692
|
+
return new i(this.valueOf() + new i(t).valueOf());
|
|
684
693
|
}
|
|
685
694
|
/**
|
|
686
695
|
* Creates a TimeSpan representing the duration between the two timestamps.
|
|
@@ -688,7 +697,7 @@ class a extends M {
|
|
|
688
697
|
* @param other
|
|
689
698
|
*/
|
|
690
699
|
sub(t) {
|
|
691
|
-
return new
|
|
700
|
+
return new i(this.valueOf() - new i(t).valueOf());
|
|
692
701
|
}
|
|
693
702
|
/**
|
|
694
703
|
* Creates a TimeSpan representing the given number of nanoseconds.
|
|
@@ -697,10 +706,10 @@ class a extends M {
|
|
|
697
706
|
* @returns A TimeSpan representing the given number of nanoseconds.
|
|
698
707
|
*/
|
|
699
708
|
static nanoseconds(t = 1) {
|
|
700
|
-
return new
|
|
709
|
+
return new i(t);
|
|
701
710
|
}
|
|
702
711
|
/** A nanosecond. */
|
|
703
|
-
static NANOSECOND =
|
|
712
|
+
static NANOSECOND = i.nanoseconds(1);
|
|
704
713
|
/**
|
|
705
714
|
* Creates a TimeSpan representing the given number of microseconds.
|
|
706
715
|
*
|
|
@@ -708,10 +717,10 @@ class a extends M {
|
|
|
708
717
|
* @returns A TimeSpan representing the given number of microseconds.
|
|
709
718
|
*/
|
|
710
719
|
static microseconds(t = 1) {
|
|
711
|
-
return
|
|
720
|
+
return i.nanoseconds(N(t, 1e3));
|
|
712
721
|
}
|
|
713
722
|
/** A microsecond. */
|
|
714
|
-
static MICROSECOND =
|
|
723
|
+
static MICROSECOND = i.microseconds(1);
|
|
715
724
|
/**
|
|
716
725
|
* Creates a TimeSpan representing the given number of milliseconds.
|
|
717
726
|
*
|
|
@@ -719,10 +728,10 @@ class a extends M {
|
|
|
719
728
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
720
729
|
*/
|
|
721
730
|
static milliseconds(t = 1) {
|
|
722
|
-
return
|
|
731
|
+
return i.microseconds(N(t, 1e3));
|
|
723
732
|
}
|
|
724
733
|
/** A millisecond. */
|
|
725
|
-
static MILLISECOND =
|
|
734
|
+
static MILLISECOND = i.milliseconds(1);
|
|
726
735
|
/**
|
|
727
736
|
* Creates a TimeSpan representing the given number of seconds.
|
|
728
737
|
*
|
|
@@ -730,10 +739,10 @@ class a extends M {
|
|
|
730
739
|
* @returns A TimeSpan representing the given number of seconds.
|
|
731
740
|
*/
|
|
732
741
|
static seconds(t = 1) {
|
|
733
|
-
return
|
|
742
|
+
return i.milliseconds(N(t, 1e3));
|
|
734
743
|
}
|
|
735
744
|
/** A second. */
|
|
736
|
-
static SECOND =
|
|
745
|
+
static SECOND = i.seconds(1);
|
|
737
746
|
/**
|
|
738
747
|
* Creates a TimeSpan representing the given number of minutes.
|
|
739
748
|
*
|
|
@@ -741,10 +750,10 @@ class a extends M {
|
|
|
741
750
|
* @returns A TimeSpan representing the given number of minutes.
|
|
742
751
|
*/
|
|
743
752
|
static minutes(t = 1) {
|
|
744
|
-
return
|
|
753
|
+
return i.seconds(N(t, 60));
|
|
745
754
|
}
|
|
746
755
|
/** A minute. */
|
|
747
|
-
static MINUTE =
|
|
756
|
+
static MINUTE = i.minutes(1);
|
|
748
757
|
/**
|
|
749
758
|
* Creates a TimeSpan representing the given number of hours.
|
|
750
759
|
*
|
|
@@ -752,10 +761,10 @@ class a extends M {
|
|
|
752
761
|
* @returns A TimeSpan representing the given number of hours.
|
|
753
762
|
*/
|
|
754
763
|
static hours(t) {
|
|
755
|
-
return
|
|
764
|
+
return i.minutes(N(t, 60));
|
|
756
765
|
}
|
|
757
766
|
/** Represents an hour. */
|
|
758
|
-
static HOUR =
|
|
767
|
+
static HOUR = i.hours(1);
|
|
759
768
|
/**
|
|
760
769
|
* Creates a TimeSpan representing the given number of days.
|
|
761
770
|
*
|
|
@@ -763,25 +772,28 @@ class a extends M {
|
|
|
763
772
|
* @returns A TimeSpan representing the given number of days.
|
|
764
773
|
*/
|
|
765
774
|
static days(t) {
|
|
766
|
-
return
|
|
775
|
+
return i.hours(N(t, 24));
|
|
767
776
|
}
|
|
768
777
|
/** Represents a day. */
|
|
769
|
-
static DAY =
|
|
778
|
+
static DAY = i.days(1);
|
|
770
779
|
/** The maximum possible value for a TimeSpan. */
|
|
771
|
-
static MAX = new
|
|
780
|
+
static MAX = new i((1n << 63n) - 1n);
|
|
772
781
|
/** The minimum possible value for a TimeSpan. */
|
|
773
|
-
static MIN = new
|
|
782
|
+
static MIN = new i(0);
|
|
774
783
|
/** The zero value for a TimeSpan. */
|
|
775
|
-
static ZERO = new
|
|
784
|
+
static ZERO = new i(0);
|
|
776
785
|
/** A zod schema for validating and transforming timespans */
|
|
777
786
|
static z = o.union([
|
|
778
|
-
o.object({ value: o.bigint() }).transform((t) => new
|
|
779
|
-
o.string().transform((t) => new
|
|
780
|
-
o.number().transform((t) => new
|
|
781
|
-
o.
|
|
787
|
+
o.object({ value: o.bigint() }).transform((t) => new i(t.value)),
|
|
788
|
+
o.string().transform((t) => new i(BigInt(t))),
|
|
789
|
+
o.number().transform((t) => new i(t)),
|
|
790
|
+
o.bigint().transform((t) => new i(t)),
|
|
791
|
+
o.instanceof(i),
|
|
792
|
+
o.instanceof(r).transform((t) => new i(t)),
|
|
793
|
+
o.custom((t) => t instanceof I).transform((t) => new i(t))
|
|
782
794
|
]);
|
|
783
795
|
}
|
|
784
|
-
class
|
|
796
|
+
class I extends C {
|
|
785
797
|
constructor(t) {
|
|
786
798
|
super(t.valueOf());
|
|
787
799
|
}
|
|
@@ -791,7 +803,7 @@ class E extends M {
|
|
|
791
803
|
}
|
|
792
804
|
/** @returns The number of seconds in the Rate. */
|
|
793
805
|
equals(t) {
|
|
794
|
-
return this.valueOf() === new
|
|
806
|
+
return this.valueOf() === new I(t).valueOf();
|
|
795
807
|
}
|
|
796
808
|
/**
|
|
797
809
|
* Calculates the period of the Rate as a TimeSpan.
|
|
@@ -799,7 +811,7 @@ class E extends M {
|
|
|
799
811
|
* @returns A TimeSpan representing the period of the Rate.
|
|
800
812
|
*/
|
|
801
813
|
get period() {
|
|
802
|
-
return
|
|
814
|
+
return i.seconds(1 / this.valueOf());
|
|
803
815
|
}
|
|
804
816
|
/**
|
|
805
817
|
* Calculates the number of samples in the given TimeSpan at this rate.
|
|
@@ -808,7 +820,7 @@ class E extends M {
|
|
|
808
820
|
* @returns The number of samples in the given TimeSpan at this rate.
|
|
809
821
|
*/
|
|
810
822
|
sampleCount(t) {
|
|
811
|
-
return new
|
|
823
|
+
return new i(t).seconds * this.valueOf();
|
|
812
824
|
}
|
|
813
825
|
/**
|
|
814
826
|
* Calculates the number of bytes in the given TimeSpan at this rate.
|
|
@@ -827,7 +839,7 @@ class E extends M {
|
|
|
827
839
|
* @returns A TimeSpan that corresponds to the given number of samples.
|
|
828
840
|
*/
|
|
829
841
|
span(t) {
|
|
830
|
-
return
|
|
842
|
+
return i.seconds(t / this.valueOf());
|
|
831
843
|
}
|
|
832
844
|
/**
|
|
833
845
|
* Calculates a TimeSpan given the number of bytes at this rate.
|
|
@@ -839,6 +851,42 @@ class E extends M {
|
|
|
839
851
|
byteSpan(t, e) {
|
|
840
852
|
return this.span(t.valueOf() / e.valueOf());
|
|
841
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* Adds another Rate to this Rate.
|
|
856
|
+
*
|
|
857
|
+
* @param other - The Rate to add.
|
|
858
|
+
* @returns A new Rate representing the sum of the two rates.
|
|
859
|
+
*/
|
|
860
|
+
add(t) {
|
|
861
|
+
return new I(L(this.valueOf(), t.valueOf()));
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Subtracts another Rate from this Rate.
|
|
865
|
+
*
|
|
866
|
+
* @param other - The Rate to subtract.
|
|
867
|
+
* @returns A new Rate representing the difference of the two rates.
|
|
868
|
+
*/
|
|
869
|
+
sub(t) {
|
|
870
|
+
return new I(S(this.valueOf(), t.valueOf()));
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Multiplies this Rate by a scalar value.
|
|
874
|
+
*
|
|
875
|
+
* @param value - The scalar value to multiply by.
|
|
876
|
+
* @returns A new Rate representing this Rate multiplied by the value.
|
|
877
|
+
*/
|
|
878
|
+
mult(t) {
|
|
879
|
+
return new I(N(this.valueOf(), t));
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Divides this Rate by a scalar value.
|
|
883
|
+
*
|
|
884
|
+
* @param value - The scalar value to divide by.
|
|
885
|
+
* @returns A new Rate representing this Rate divided by the value.
|
|
886
|
+
*/
|
|
887
|
+
div(t) {
|
|
888
|
+
return new I(p(this.valueOf(), t));
|
|
889
|
+
}
|
|
842
890
|
/**
|
|
843
891
|
* Creates a Rate representing the given number of Hz.
|
|
844
892
|
*
|
|
@@ -846,7 +894,7 @@ class E extends M {
|
|
|
846
894
|
* @returns A Rate representing the given number of Hz.
|
|
847
895
|
*/
|
|
848
896
|
static hz(t) {
|
|
849
|
-
return new
|
|
897
|
+
return new I(t);
|
|
850
898
|
}
|
|
851
899
|
/**
|
|
852
900
|
* Creates a Rate representing the given number of kHz.
|
|
@@ -855,15 +903,15 @@ class E extends M {
|
|
|
855
903
|
* @returns A Rate representing the given number of kHz.
|
|
856
904
|
*/
|
|
857
905
|
static khz(t) {
|
|
858
|
-
return
|
|
906
|
+
return I.hz(t * 1e3);
|
|
859
907
|
}
|
|
860
908
|
/** A zod schema for validating and transforming rates */
|
|
861
909
|
static z = o.union([
|
|
862
|
-
o.number().transform((t) => new
|
|
863
|
-
o.instanceof(
|
|
910
|
+
o.number().transform((t) => new I(t)),
|
|
911
|
+
o.instanceof(I)
|
|
864
912
|
]);
|
|
865
913
|
}
|
|
866
|
-
class d extends
|
|
914
|
+
class d extends C {
|
|
867
915
|
/**
|
|
868
916
|
* Creates a Density representing the given number of bytes per value.
|
|
869
917
|
*
|
|
@@ -890,7 +938,43 @@ class d extends M {
|
|
|
890
938
|
* @returns A Size representing the given number of values.
|
|
891
939
|
*/
|
|
892
940
|
size(t) {
|
|
893
|
-
return new
|
|
941
|
+
return new c(t * this.valueOf());
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Adds another Density to this Density.
|
|
945
|
+
*
|
|
946
|
+
* @param other - The Density to add.
|
|
947
|
+
* @returns A new Density representing the sum of the two densities.
|
|
948
|
+
*/
|
|
949
|
+
add(t) {
|
|
950
|
+
return new d(L(this.valueOf(), t.valueOf()));
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Subtracts another Density from this Density.
|
|
954
|
+
*
|
|
955
|
+
* @param other - The Density to subtract.
|
|
956
|
+
* @returns A new Density representing the difference of the two densities.
|
|
957
|
+
*/
|
|
958
|
+
sub(t) {
|
|
959
|
+
return new d(S(this.valueOf(), t.valueOf()));
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Multiplies this Density by a scalar value.
|
|
963
|
+
*
|
|
964
|
+
* @param value - The scalar value to multiply by.
|
|
965
|
+
* @returns A new Density representing this Density multiplied by the value.
|
|
966
|
+
*/
|
|
967
|
+
mult(t) {
|
|
968
|
+
return new d(N(this.valueOf(), t));
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Divides this Density by a scalar value.
|
|
972
|
+
*
|
|
973
|
+
* @param value - The scalar value to divide by.
|
|
974
|
+
* @returns A new Density representing this Density divided by the value.
|
|
975
|
+
*/
|
|
976
|
+
div(t) {
|
|
977
|
+
return new d(p(this.valueOf(), t));
|
|
894
978
|
}
|
|
895
979
|
/** Unknown/Invalid Density. */
|
|
896
980
|
static UNKNOWN = new d(0);
|
|
@@ -910,7 +994,7 @@ class d extends M {
|
|
|
910
994
|
o.instanceof(d)
|
|
911
995
|
]);
|
|
912
996
|
}
|
|
913
|
-
class
|
|
997
|
+
class O {
|
|
914
998
|
/**
|
|
915
999
|
* The starting TimeStamp of the TimeRange.
|
|
916
1000
|
*
|
|
@@ -936,11 +1020,11 @@ class w {
|
|
|
936
1020
|
* @param end - A TimeStamp representing the end of the range.
|
|
937
1021
|
*/
|
|
938
1022
|
constructor(t, e) {
|
|
939
|
-
typeof t == "object" && "start" in t ? (this.start = new
|
|
1023
|
+
typeof t == "object" && "start" in t ? (this.start = new r(t.start), this.end = new r(t.end)) : (this.start = new r(t), this.end = new r(e));
|
|
940
1024
|
}
|
|
941
1025
|
/** @returns The TimeSpan occupied by the TimeRange. */
|
|
942
1026
|
get span() {
|
|
943
|
-
return new
|
|
1027
|
+
return new i(this.end.valueOf() - this.start.valueOf());
|
|
944
1028
|
}
|
|
945
1029
|
/**
|
|
946
1030
|
* Checks if the timestamp is valid i.e. the start is before the end.
|
|
@@ -978,7 +1062,7 @@ class w {
|
|
|
978
1062
|
* @returns A TimeRange with the start and end swapped.
|
|
979
1063
|
*/
|
|
980
1064
|
swap() {
|
|
981
|
-
return new
|
|
1065
|
+
return new O(this.end, this.start);
|
|
982
1066
|
}
|
|
983
1067
|
get numericBounds() {
|
|
984
1068
|
return {
|
|
@@ -992,7 +1076,7 @@ class w {
|
|
|
992
1076
|
* @param other - The TimeRange to compare to.
|
|
993
1077
|
* @returns True if the TimeRange is equal to the given TimeRange.
|
|
994
1078
|
*/
|
|
995
|
-
equals(t, e =
|
|
1079
|
+
equals(t, e = i.ZERO) {
|
|
996
1080
|
if (e.isZero)
|
|
997
1081
|
return this.start.equals(t.start) && this.end.equals(t.end);
|
|
998
1082
|
let s = this.start.sub(t.start).valueOf(), u = this.end.sub(t.end).valueOf();
|
|
@@ -1025,16 +1109,16 @@ class w {
|
|
|
1025
1109
|
* checking for overlap.
|
|
1026
1110
|
* @returns True if the two TimeRanges overlap, false otherwise.
|
|
1027
1111
|
*/
|
|
1028
|
-
overlapsWith(t, e =
|
|
1112
|
+
overlapsWith(t, e = i.ZERO) {
|
|
1029
1113
|
t = t.makeValid();
|
|
1030
1114
|
const s = this.makeValid();
|
|
1031
1115
|
if (this.equals(t)) return !0;
|
|
1032
1116
|
if (t.end.equals(s.start) || s.end.equals(t.start)) return !1;
|
|
1033
|
-
const u =
|
|
1034
|
-
return
|
|
1117
|
+
const u = r.max(s.start, t.start), l = r.min(s.end, t.end);
|
|
1118
|
+
return l.before(u) ? !1 : new i(l.sub(u)).greaterThanOrEqual(e);
|
|
1035
1119
|
}
|
|
1036
1120
|
contains(t) {
|
|
1037
|
-
return t instanceof
|
|
1121
|
+
return t instanceof O ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
|
|
1038
1122
|
}
|
|
1039
1123
|
/**
|
|
1040
1124
|
* Returns a new TimeRange that is bound by the given TimeRange.
|
|
@@ -1048,25 +1132,25 @@ class w {
|
|
|
1048
1132
|
* console.log(bounded); // TimeRange(1500, 2000)
|
|
1049
1133
|
*/
|
|
1050
1134
|
boundBy(t) {
|
|
1051
|
-
const e = new
|
|
1135
|
+
const e = new O(this.start, this.end);
|
|
1052
1136
|
return t.start.after(this.start) && (e.start = t.start), t.start.after(this.end) && (e.end = t.start), t.end.before(this.end) && (e.end = t.end), t.end.before(this.start) && (e.start = t.end), e;
|
|
1053
1137
|
}
|
|
1054
1138
|
static max(...t) {
|
|
1055
|
-
return new
|
|
1056
|
-
|
|
1057
|
-
|
|
1139
|
+
return new O(
|
|
1140
|
+
r.min(...t.map((e) => e.start)),
|
|
1141
|
+
r.max(...t.map((e) => e.end))
|
|
1058
1142
|
);
|
|
1059
1143
|
}
|
|
1060
1144
|
/** The maximum possible time range. */
|
|
1061
|
-
static MAX = new
|
|
1145
|
+
static MAX = new O(r.MIN, r.MAX);
|
|
1062
1146
|
/** The minimum possible time range. */
|
|
1063
|
-
static MIN = new
|
|
1147
|
+
static MIN = new O(r.MAX, r.MIN);
|
|
1064
1148
|
/** A time range whose start and end are both zero. */
|
|
1065
|
-
static ZERO = new
|
|
1149
|
+
static ZERO = new O(r.ZERO, r.ZERO);
|
|
1066
1150
|
/** A zod schema for validating and transforming time ranges */
|
|
1067
1151
|
static z = o.union([
|
|
1068
|
-
o.object({ start:
|
|
1069
|
-
o.instanceof(
|
|
1152
|
+
o.object({ start: r.z, end: r.z }).transform((t) => new O(t.start, t.end)),
|
|
1153
|
+
o.instanceof(O)
|
|
1070
1154
|
]);
|
|
1071
1155
|
/**
|
|
1072
1156
|
* Sorts two time ranges. The range with the earlier start time is considered less than
|
|
@@ -1080,15 +1164,31 @@ class w {
|
|
|
1080
1164
|
* equal.
|
|
1081
1165
|
*/
|
|
1082
1166
|
static sort(t, e) {
|
|
1083
|
-
return
|
|
1167
|
+
return r.sort(t.start, e.start) || r.sort(t.end, e.end);
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Simplify takes the list of `TimeRange`s, makes all of them valid, sorts them, and
|
|
1171
|
+
* merges any overlapping ranges.
|
|
1172
|
+
*
|
|
1173
|
+
* @param ranges - The list of `TimeRange`s to simplify.
|
|
1174
|
+
* @returns A list of simplified `TimeRange`s.
|
|
1175
|
+
*/
|
|
1176
|
+
static simplify(t) {
|
|
1177
|
+
return t.map((e) => e.makeValid()).sort((e, s) => O.sort(e, s)).reduce((e, s) => {
|
|
1178
|
+
if (s.isZero) return e;
|
|
1179
|
+
if (e.length === 0)
|
|
1180
|
+
return e.push(s), e;
|
|
1181
|
+
const u = e[e.length - 1];
|
|
1182
|
+
return u.overlapsWith(s) || u.end.equals(s.start) ? u.end = r.max(u.end, s.end) : e.push(s), e;
|
|
1183
|
+
}, []);
|
|
1084
1184
|
}
|
|
1085
1185
|
}
|
|
1086
|
-
class
|
|
1186
|
+
class n extends C {
|
|
1087
1187
|
constructor(t) {
|
|
1088
|
-
if (t instanceof
|
|
1188
|
+
if (t instanceof n || typeof t == "string" || typeof t.valueOf() == "string")
|
|
1089
1189
|
super(t.valueOf());
|
|
1090
1190
|
else {
|
|
1091
|
-
const e =
|
|
1191
|
+
const e = n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
|
|
1092
1192
|
if (e == null)
|
|
1093
1193
|
throw new Error(`unable to find data type for ${t.toString()}`);
|
|
1094
1194
|
super(e.valueOf());
|
|
@@ -1098,7 +1198,7 @@ class r extends M {
|
|
|
1098
1198
|
* @returns the TypedArray constructor for the DataType.
|
|
1099
1199
|
*/
|
|
1100
1200
|
get Array() {
|
|
1101
|
-
const t =
|
|
1201
|
+
const t = n.ARRAY_CONSTRUCTORS.get(this.toString());
|
|
1102
1202
|
if (t == null)
|
|
1103
1203
|
throw new Error(`unable to find array constructor for ${this.valueOf()}`);
|
|
1104
1204
|
return t;
|
|
@@ -1125,7 +1225,7 @@ class r extends M {
|
|
|
1125
1225
|
* @example DataType.INT32.isVariable // false
|
|
1126
1226
|
*/
|
|
1127
1227
|
get isVariable() {
|
|
1128
|
-
return this.equals(
|
|
1228
|
+
return this.equals(n.JSON) || this.equals(n.STRING);
|
|
1129
1229
|
}
|
|
1130
1230
|
/**
|
|
1131
1231
|
* @returns true if the DataType is numeric.
|
|
@@ -1133,7 +1233,7 @@ class r extends M {
|
|
|
1133
1233
|
* @example DataType.STRING.isNumeric // false
|
|
1134
1234
|
*/
|
|
1135
1235
|
get isNumeric() {
|
|
1136
|
-
return !this.isVariable && !this.equals(
|
|
1236
|
+
return !this.isVariable && !this.equals(n.UUID);
|
|
1137
1237
|
}
|
|
1138
1238
|
/**
|
|
1139
1239
|
* @returns true if the DataType is an integer.
|
|
@@ -1158,7 +1258,7 @@ class r extends M {
|
|
|
1158
1258
|
* @example DataType.FLOAT32.density // Density.BIT32
|
|
1159
1259
|
*/
|
|
1160
1260
|
get density() {
|
|
1161
|
-
const t =
|
|
1261
|
+
const t = n.DENSITIES.get(this.toString());
|
|
1162
1262
|
if (t == null) throw new Error(`unable to find density for ${this.valueOf()}`);
|
|
1163
1263
|
return t;
|
|
1164
1264
|
}
|
|
@@ -1168,7 +1268,7 @@ class r extends M {
|
|
|
1168
1268
|
* @example DataType.INT32.isUnsigned // false
|
|
1169
1269
|
*/
|
|
1170
1270
|
get isUnsignedInteger() {
|
|
1171
|
-
return this.equals(
|
|
1271
|
+
return this.equals(n.UINT8) || this.equals(n.UINT16) || this.equals(n.UINT32) || this.equals(n.UINT64);
|
|
1172
1272
|
}
|
|
1173
1273
|
/**
|
|
1174
1274
|
* @returns true if the DataType is a signed integer.
|
|
@@ -1176,11 +1276,11 @@ class r extends M {
|
|
|
1176
1276
|
* @example DataType.UINT32.isSigned // false
|
|
1177
1277
|
*/
|
|
1178
1278
|
get isSignedInteger() {
|
|
1179
|
-
return this.equals(
|
|
1279
|
+
return this.equals(n.INT8) || this.equals(n.INT16) || this.equals(n.INT32) || this.equals(n.INT64);
|
|
1180
1280
|
}
|
|
1181
1281
|
/** @returns true if the data type can be cast to the other data type without loss of precision. */
|
|
1182
1282
|
canSafelyCastTo(t) {
|
|
1183
|
-
return this.equals(t) ? !0 : !this.isNumeric || !t.isNumeric || this.isVariable || t.isVariable || this.isUnsignedInteger && t.isSignedInteger ? !1 : this.isFloat ? t.isFloat && this.density.valueOf() <= t.density.valueOf() : this.equals(
|
|
1283
|
+
return this.equals(t) ? !0 : !this.isNumeric || !t.isNumeric || this.isVariable || t.isVariable || this.isUnsignedInteger && t.isSignedInteger ? !1 : this.isFloat ? t.isFloat && this.density.valueOf() <= t.density.valueOf() : this.equals(n.INT32) && t.equals(n.FLOAT64) || this.equals(n.INT8) && t.equals(n.FLOAT32) ? !0 : this.isInteger && t.isInteger ? this.density.valueOf() <= t.density.valueOf() && this.isUnsignedInteger === t.isUnsignedInteger : !1;
|
|
1184
1284
|
}
|
|
1185
1285
|
/** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
|
|
1186
1286
|
canCastTo(t) {
|
|
@@ -1197,112 +1297,112 @@ class r extends M {
|
|
|
1197
1297
|
}
|
|
1198
1298
|
/** @returns true if the data type uses bigints to store values. */
|
|
1199
1299
|
get usesBigInt() {
|
|
1200
|
-
return
|
|
1300
|
+
return n.BIG_INT_TYPES.some((t) => t.equals(this));
|
|
1201
1301
|
}
|
|
1202
1302
|
/** Represents an Unknown/Invalid DataType. */
|
|
1203
|
-
static UNKNOWN = new
|
|
1303
|
+
static UNKNOWN = new n("unknown");
|
|
1204
1304
|
/** Represents a 64-bit floating point value. */
|
|
1205
|
-
static FLOAT64 = new
|
|
1305
|
+
static FLOAT64 = new n("float64");
|
|
1206
1306
|
/** Represents a 32-bit floating point value. */
|
|
1207
|
-
static FLOAT32 = new
|
|
1307
|
+
static FLOAT32 = new n("float32");
|
|
1208
1308
|
/** Represents a 64-bit signed integer value. */
|
|
1209
|
-
static INT64 = new
|
|
1309
|
+
static INT64 = new n("int64");
|
|
1210
1310
|
/** Represents a 32-bit signed integer value. */
|
|
1211
|
-
static INT32 = new
|
|
1311
|
+
static INT32 = new n("int32");
|
|
1212
1312
|
/** Represents a 16-bit signed integer value. */
|
|
1213
|
-
static INT16 = new
|
|
1313
|
+
static INT16 = new n("int16");
|
|
1214
1314
|
/** Represents a 8-bit signed integer value. */
|
|
1215
|
-
static INT8 = new
|
|
1315
|
+
static INT8 = new n("int8");
|
|
1216
1316
|
/** Represents a 64-bit unsigned integer value. */
|
|
1217
|
-
static UINT64 = new
|
|
1317
|
+
static UINT64 = new n("uint64");
|
|
1218
1318
|
/** Represents a 32-bit unsigned integer value. */
|
|
1219
|
-
static UINT32 = new
|
|
1319
|
+
static UINT32 = new n("uint32");
|
|
1220
1320
|
/** Represents a 16-bit unsigned integer value. */
|
|
1221
|
-
static UINT16 = new
|
|
1321
|
+
static UINT16 = new n("uint16");
|
|
1222
1322
|
/** Represents a 8-bit unsigned integer value. */
|
|
1223
|
-
static UINT8 = new
|
|
1323
|
+
static UINT8 = new n("uint8");
|
|
1224
1324
|
/** Represents a boolean value. Alias for UINT8. */
|
|
1225
1325
|
static BOOLEAN = this.UINT8;
|
|
1226
1326
|
/** Represents a 64-bit unix epoch. */
|
|
1227
|
-
static TIMESTAMP = new
|
|
1327
|
+
static TIMESTAMP = new n("timestamp");
|
|
1228
1328
|
/** Represents a UUID data type */
|
|
1229
|
-
static UUID = new
|
|
1329
|
+
static UUID = new n("uuid");
|
|
1230
1330
|
/** Represents a string data type. Strings have an unknown density, and are separate
|
|
1231
1331
|
* by a newline character. */
|
|
1232
|
-
static STRING = new
|
|
1332
|
+
static STRING = new n("string");
|
|
1233
1333
|
/** Represents a JSON data type. JSON has an unknown density, and is separated by a
|
|
1234
1334
|
* newline character. */
|
|
1235
|
-
static JSON = new
|
|
1335
|
+
static JSON = new n("json");
|
|
1236
1336
|
static ARRAY_CONSTRUCTORS = /* @__PURE__ */ new Map([
|
|
1237
|
-
[
|
|
1238
|
-
[
|
|
1239
|
-
[
|
|
1240
|
-
[
|
|
1241
|
-
[
|
|
1242
|
-
[
|
|
1243
|
-
[
|
|
1244
|
-
[
|
|
1245
|
-
[
|
|
1246
|
-
[
|
|
1247
|
-
[
|
|
1248
|
-
[
|
|
1249
|
-
[
|
|
1250
|
-
[
|
|
1337
|
+
[n.UINT8.toString(), Uint8Array],
|
|
1338
|
+
[n.UINT16.toString(), Uint16Array],
|
|
1339
|
+
[n.UINT32.toString(), Uint32Array],
|
|
1340
|
+
[n.UINT64.toString(), BigUint64Array],
|
|
1341
|
+
[n.FLOAT32.toString(), Float32Array],
|
|
1342
|
+
[n.FLOAT64.toString(), Float64Array],
|
|
1343
|
+
[n.INT8.toString(), Int8Array],
|
|
1344
|
+
[n.INT16.toString(), Int16Array],
|
|
1345
|
+
[n.INT32.toString(), Int32Array],
|
|
1346
|
+
[n.INT64.toString(), BigInt64Array],
|
|
1347
|
+
[n.TIMESTAMP.toString(), BigInt64Array],
|
|
1348
|
+
[n.STRING.toString(), Uint8Array],
|
|
1349
|
+
[n.JSON.toString(), Uint8Array],
|
|
1350
|
+
[n.UUID.toString(), Uint8Array]
|
|
1251
1351
|
]);
|
|
1252
1352
|
static ARRAY_CONSTRUCTOR_DATA_TYPES = /* @__PURE__ */ new Map([
|
|
1253
|
-
[Uint8Array.name,
|
|
1254
|
-
[Uint16Array.name,
|
|
1255
|
-
[Uint32Array.name,
|
|
1256
|
-
[BigUint64Array.name,
|
|
1257
|
-
[Float32Array.name,
|
|
1258
|
-
[Float64Array.name,
|
|
1259
|
-
[Int8Array.name,
|
|
1260
|
-
[Int16Array.name,
|
|
1261
|
-
[Int32Array.name,
|
|
1262
|
-
[BigInt64Array.name,
|
|
1353
|
+
[Uint8Array.name, n.UINT8],
|
|
1354
|
+
[Uint16Array.name, n.UINT16],
|
|
1355
|
+
[Uint32Array.name, n.UINT32],
|
|
1356
|
+
[BigUint64Array.name, n.UINT64],
|
|
1357
|
+
[Float32Array.name, n.FLOAT32],
|
|
1358
|
+
[Float64Array.name, n.FLOAT64],
|
|
1359
|
+
[Int8Array.name, n.INT8],
|
|
1360
|
+
[Int16Array.name, n.INT16],
|
|
1361
|
+
[Int32Array.name, n.INT32],
|
|
1362
|
+
[BigInt64Array.name, n.INT64]
|
|
1263
1363
|
]);
|
|
1264
1364
|
static DENSITIES = /* @__PURE__ */ new Map([
|
|
1265
|
-
[
|
|
1266
|
-
[
|
|
1267
|
-
[
|
|
1268
|
-
[
|
|
1269
|
-
[
|
|
1270
|
-
[
|
|
1271
|
-
[
|
|
1272
|
-
[
|
|
1273
|
-
[
|
|
1274
|
-
[
|
|
1275
|
-
[
|
|
1276
|
-
[
|
|
1277
|
-
[
|
|
1278
|
-
[
|
|
1365
|
+
[n.UINT8.toString(), d.BIT8],
|
|
1366
|
+
[n.UINT16.toString(), d.BIT16],
|
|
1367
|
+
[n.UINT32.toString(), d.BIT32],
|
|
1368
|
+
[n.UINT64.toString(), d.BIT64],
|
|
1369
|
+
[n.FLOAT32.toString(), d.BIT32],
|
|
1370
|
+
[n.FLOAT64.toString(), d.BIT64],
|
|
1371
|
+
[n.INT8.toString(), d.BIT8],
|
|
1372
|
+
[n.INT16.toString(), d.BIT16],
|
|
1373
|
+
[n.INT32.toString(), d.BIT32],
|
|
1374
|
+
[n.INT64.toString(), d.BIT64],
|
|
1375
|
+
[n.TIMESTAMP.toString(), d.BIT64],
|
|
1376
|
+
[n.STRING.toString(), d.UNKNOWN],
|
|
1377
|
+
[n.JSON.toString(), d.UNKNOWN],
|
|
1378
|
+
[n.UUID.toString(), d.BIT128]
|
|
1279
1379
|
]);
|
|
1280
1380
|
/** All the data types. */
|
|
1281
1381
|
static ALL = [
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1382
|
+
n.UNKNOWN,
|
|
1383
|
+
n.FLOAT64,
|
|
1384
|
+
n.FLOAT32,
|
|
1385
|
+
n.INT64,
|
|
1386
|
+
n.INT32,
|
|
1387
|
+
n.INT16,
|
|
1388
|
+
n.INT8,
|
|
1389
|
+
n.UINT64,
|
|
1390
|
+
n.UINT32,
|
|
1391
|
+
n.UINT16,
|
|
1392
|
+
n.UINT8,
|
|
1393
|
+
n.TIMESTAMP,
|
|
1394
|
+
n.UUID,
|
|
1395
|
+
n.STRING,
|
|
1396
|
+
n.JSON
|
|
1297
1397
|
];
|
|
1298
|
-
static BIG_INT_TYPES = [
|
|
1398
|
+
static BIG_INT_TYPES = [n.INT64, n.UINT64, n.TIMESTAMP];
|
|
1299
1399
|
/** A zod schema for a DataType. */
|
|
1300
1400
|
static z = o.union([
|
|
1301
|
-
o.string().transform((t) => new
|
|
1302
|
-
o.instanceof(
|
|
1401
|
+
o.string().transform((t) => new n(t)),
|
|
1402
|
+
o.instanceof(n)
|
|
1303
1403
|
]);
|
|
1304
1404
|
}
|
|
1305
|
-
class
|
|
1405
|
+
class c extends C {
|
|
1306
1406
|
constructor(t) {
|
|
1307
1407
|
super(t.valueOf());
|
|
1308
1408
|
}
|
|
@@ -1316,41 +1416,59 @@ class h extends M {
|
|
|
1316
1416
|
}
|
|
1317
1417
|
/** @returns a new Size representing the sum of the two Sizes. */
|
|
1318
1418
|
add(t) {
|
|
1319
|
-
return
|
|
1419
|
+
return new c(L(this.valueOf(), t.valueOf()));
|
|
1320
1420
|
}
|
|
1321
1421
|
/** @returns a new Size representing the difference of the two Sizes. */
|
|
1322
1422
|
sub(t) {
|
|
1323
|
-
return
|
|
1423
|
+
return new c(S(this.valueOf(), t.valueOf()));
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Multiplies this Size by a scalar value.
|
|
1427
|
+
*
|
|
1428
|
+
* @param value - The scalar value to multiply by.
|
|
1429
|
+
* @returns A new Size representing this Size multiplied by the value.
|
|
1430
|
+
*/
|
|
1431
|
+
mult(t) {
|
|
1432
|
+
return new c(N(this.valueOf(), t));
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Divides this Size by a scalar value.
|
|
1436
|
+
*
|
|
1437
|
+
* @param value - The scalar value to divide by.
|
|
1438
|
+
* @returns A new Size representing this Size divided by the value.
|
|
1439
|
+
*/
|
|
1440
|
+
div(t) {
|
|
1441
|
+
return new c(p(this.valueOf(), t));
|
|
1324
1442
|
}
|
|
1325
1443
|
/** @returns a new Size representing the truncated value of the Size. */
|
|
1326
1444
|
truncate(t) {
|
|
1327
|
-
return new
|
|
1445
|
+
return new c(Math.trunc(this.valueOf() / t.valueOf()) * t.valueOf());
|
|
1328
1446
|
}
|
|
1329
1447
|
/** @returns a new Size representing the remainder of the Size. */
|
|
1330
1448
|
remainder(t) {
|
|
1331
|
-
return
|
|
1449
|
+
return c.bytes(this.valueOf() % t.valueOf());
|
|
1332
1450
|
}
|
|
1333
1451
|
/** @returns the number of gigabytes in the Size. */
|
|
1334
1452
|
get gigabytes() {
|
|
1335
|
-
return this.valueOf() /
|
|
1453
|
+
return this.valueOf() / c.GIGABYTE.valueOf();
|
|
1336
1454
|
}
|
|
1337
1455
|
/** @returns the number of megabytes in the Size. */
|
|
1338
1456
|
get megabytes() {
|
|
1339
|
-
return this.valueOf() /
|
|
1457
|
+
return this.valueOf() / c.MEGABYTE.valueOf();
|
|
1340
1458
|
}
|
|
1341
1459
|
/** @returns the number of kilobytes in the Size. */
|
|
1342
1460
|
get kilobytes() {
|
|
1343
|
-
return this.valueOf() /
|
|
1461
|
+
return this.valueOf() / c.KILOBYTE.valueOf();
|
|
1344
1462
|
}
|
|
1345
1463
|
/** @returns the number of terabytes in the Size. */
|
|
1346
1464
|
get terabytes() {
|
|
1347
|
-
return this.valueOf() /
|
|
1465
|
+
return this.valueOf() / c.TERABYTE.valueOf();
|
|
1348
1466
|
}
|
|
1349
1467
|
/** @returns a nicely formatted string representation of the Size. */
|
|
1350
1468
|
toString() {
|
|
1351
|
-
const t = this.truncate(
|
|
1352
|
-
let
|
|
1353
|
-
return
|
|
1469
|
+
const t = this.truncate(c.TERABYTE), e = this.truncate(c.GIGABYTE), s = this.truncate(c.MEGABYTE), u = this.truncate(c.KILOBYTE), l = this.truncate(c.BYTE), h = t, U = e.sub(t), y = s.sub(e), g = u.sub(s), m = l.sub(u);
|
|
1470
|
+
let b = "";
|
|
1471
|
+
return h.isZero || (b += `${h.terabytes}TB `), U.isZero || (b += `${U.gigabytes}GB `), y.isZero || (b += `${y.megabytes}MB `), g.isZero || (b += `${g.kilobytes}KB `), (!m.isZero || b === "") && (b += `${m.valueOf()}B`), b.trim();
|
|
1354
1472
|
}
|
|
1355
1473
|
/**
|
|
1356
1474
|
* Creates a Size from the given number of bytes.
|
|
@@ -1359,10 +1477,10 @@ class h extends M {
|
|
|
1359
1477
|
* @returns A Size representing the given number of bytes.
|
|
1360
1478
|
*/
|
|
1361
1479
|
static bytes(t = 1) {
|
|
1362
|
-
return new
|
|
1480
|
+
return new c(t);
|
|
1363
1481
|
}
|
|
1364
1482
|
/** A single byte */
|
|
1365
|
-
static BYTE = new
|
|
1483
|
+
static BYTE = new c(1);
|
|
1366
1484
|
/**
|
|
1367
1485
|
* Creates a Size from the given number if kilobytes.
|
|
1368
1486
|
*
|
|
@@ -1370,10 +1488,10 @@ class h extends M {
|
|
|
1370
1488
|
* @returns A Size representing the given number of kilobytes.
|
|
1371
1489
|
*/
|
|
1372
1490
|
static kilobytes(t = 1) {
|
|
1373
|
-
return
|
|
1491
|
+
return c.bytes(t.valueOf() * 1e3);
|
|
1374
1492
|
}
|
|
1375
1493
|
/** A kilobyte */
|
|
1376
|
-
static KILOBYTE =
|
|
1494
|
+
static KILOBYTE = c.kilobytes(1);
|
|
1377
1495
|
/**
|
|
1378
1496
|
* Creates a Size from the given number of megabytes.
|
|
1379
1497
|
*
|
|
@@ -1381,10 +1499,10 @@ class h extends M {
|
|
|
1381
1499
|
* @returns A Size representing the given number of megabytes.
|
|
1382
1500
|
*/
|
|
1383
1501
|
static megabytes(t = 1) {
|
|
1384
|
-
return
|
|
1502
|
+
return c.kilobytes(t.valueOf() * 1e3);
|
|
1385
1503
|
}
|
|
1386
1504
|
/** A megabyte */
|
|
1387
|
-
static MEGABYTE =
|
|
1505
|
+
static MEGABYTE = c.megabytes(1);
|
|
1388
1506
|
/**
|
|
1389
1507
|
* Creates a Size from the given number of gigabytes.
|
|
1390
1508
|
*
|
|
@@ -1392,10 +1510,10 @@ class h extends M {
|
|
|
1392
1510
|
* @returns A Size representing the given number of gigabytes.
|
|
1393
1511
|
*/
|
|
1394
1512
|
static gigabytes(t = 1) {
|
|
1395
|
-
return
|
|
1513
|
+
return c.megabytes(t.valueOf() * 1e3);
|
|
1396
1514
|
}
|
|
1397
1515
|
/** A gigabyte */
|
|
1398
|
-
static GIGABYTE =
|
|
1516
|
+
static GIGABYTE = c.gigabytes(1);
|
|
1399
1517
|
/**
|
|
1400
1518
|
* Creates a Size from the given number of terabytes.
|
|
1401
1519
|
*
|
|
@@ -1403,23 +1521,23 @@ class h extends M {
|
|
|
1403
1521
|
* @returns A Size representing the given number of terabytes.
|
|
1404
1522
|
*/
|
|
1405
1523
|
static terabytes(t) {
|
|
1406
|
-
return
|
|
1524
|
+
return c.gigabytes(t.valueOf() * 1e3);
|
|
1407
1525
|
}
|
|
1408
1526
|
/** A terabyte. */
|
|
1409
|
-
static TERABYTE =
|
|
1527
|
+
static TERABYTE = c.terabytes(1);
|
|
1410
1528
|
/** The zero value for Size */
|
|
1411
|
-
static ZERO = new
|
|
1529
|
+
static ZERO = new c(0);
|
|
1412
1530
|
/** A zod schema for a Size. */
|
|
1413
1531
|
static z = o.union([
|
|
1414
|
-
o.number().transform((t) => new
|
|
1415
|
-
o.instanceof(
|
|
1532
|
+
o.number().transform((t) => new c(t)),
|
|
1533
|
+
o.instanceof(c)
|
|
1416
1534
|
]);
|
|
1417
1535
|
/** @returns true if the Size is zero. */
|
|
1418
1536
|
get isZero() {
|
|
1419
1537
|
return this.valueOf() === 0;
|
|
1420
1538
|
}
|
|
1421
1539
|
}
|
|
1422
|
-
const
|
|
1540
|
+
const Jt = o.union([
|
|
1423
1541
|
o.instanceof(Uint8Array),
|
|
1424
1542
|
o.instanceof(Uint16Array),
|
|
1425
1543
|
o.instanceof(Uint32Array),
|
|
@@ -1430,64 +1548,64 @@ const Yt = o.union([
|
|
|
1430
1548
|
o.instanceof(Int16Array),
|
|
1431
1549
|
o.instanceof(Int32Array),
|
|
1432
1550
|
o.instanceof(BigInt64Array)
|
|
1433
|
-
]),
|
|
1434
|
-
const t = typeof
|
|
1435
|
-
return t === "string" || t === "number" || t === "boolean" || t === "bigint" ||
|
|
1436
|
-
},
|
|
1437
|
-
function
|
|
1438
|
-
return typeof
|
|
1551
|
+
]), z = (a) => {
|
|
1552
|
+
const t = typeof a;
|
|
1553
|
+
return t === "string" || t === "number" || t === "boolean" || t === "bigint" || a instanceof r || a instanceof i || a instanceof Date;
|
|
1554
|
+
}, dt = (a, t, e, s = 0) => a.usesBigInt && !t.usesBigInt ? Number(e) - Number(s) : !a.usesBigInt && t.usesBigInt ? BigInt(e.valueOf()) - BigInt(s.valueOf()) : T(e, -s), T = (a, t) => t == 0 ? a : a == 0 ? t : typeof a == "bigint" && typeof t == "bigint" || typeof a == "number" && typeof t == "number" ? a + t : Number(a) + Number(t), gt = "00000000-0000-0000-0000-000000000000", Ot = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
1555
|
+
function wt(a) {
|
|
1556
|
+
return typeof a == "string" && Ot.test(a);
|
|
1439
1557
|
}
|
|
1440
|
-
const
|
|
1441
|
-
for (let
|
|
1442
|
-
|
|
1443
|
-
function
|
|
1444
|
-
return (
|
|
1558
|
+
const w = [];
|
|
1559
|
+
for (let a = 0; a < 256; ++a)
|
|
1560
|
+
w.push((a + 256).toString(16).slice(1));
|
|
1561
|
+
function _(a, t = 0) {
|
|
1562
|
+
return (w[a[t + 0]] + w[a[t + 1]] + w[a[t + 2]] + w[a[t + 3]] + "-" + w[a[t + 4]] + w[a[t + 5]] + "-" + w[a[t + 6]] + w[a[t + 7]] + "-" + w[a[t + 8]] + w[a[t + 9]] + "-" + w[a[t + 10]] + w[a[t + 11]] + w[a[t + 12]] + w[a[t + 13]] + w[a[t + 14]] + w[a[t + 15]]).toLowerCase();
|
|
1445
1563
|
}
|
|
1446
|
-
function
|
|
1447
|
-
const e =
|
|
1448
|
-
if (!
|
|
1564
|
+
function bt(a, t = 0) {
|
|
1565
|
+
const e = _(a, t);
|
|
1566
|
+
if (!wt(e))
|
|
1449
1567
|
throw TypeError("Stringified UUID is invalid");
|
|
1450
1568
|
return e;
|
|
1451
1569
|
}
|
|
1452
|
-
let
|
|
1453
|
-
const
|
|
1454
|
-
function
|
|
1455
|
-
if (!
|
|
1570
|
+
let q;
|
|
1571
|
+
const It = new Uint8Array(16);
|
|
1572
|
+
function yt() {
|
|
1573
|
+
if (!q) {
|
|
1456
1574
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1457
1575
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1458
|
-
|
|
1576
|
+
q = crypto.getRandomValues.bind(crypto);
|
|
1459
1577
|
}
|
|
1460
|
-
return
|
|
1578
|
+
return q(It);
|
|
1461
1579
|
}
|
|
1462
|
-
const
|
|
1463
|
-
function
|
|
1464
|
-
if (
|
|
1465
|
-
return
|
|
1466
|
-
|
|
1467
|
-
const s =
|
|
1580
|
+
const mt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), G = { randomUUID: mt };
|
|
1581
|
+
function Nt(a, t, e) {
|
|
1582
|
+
if (G.randomUUID && !a)
|
|
1583
|
+
return G.randomUUID();
|
|
1584
|
+
a = a || {};
|
|
1585
|
+
const s = a.random ?? a.rng?.() ?? yt();
|
|
1468
1586
|
if (s.length < 16)
|
|
1469
1587
|
throw new Error("Random bytes length must be >= 16");
|
|
1470
|
-
return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128,
|
|
1588
|
+
return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, _(s);
|
|
1471
1589
|
}
|
|
1472
|
-
const
|
|
1590
|
+
const vt = () => Nt(), Z = (a, t) => bt(a, t), Ut = gt, jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1473
1591
|
__proto__: null,
|
|
1474
|
-
ZERO:
|
|
1475
|
-
create:
|
|
1476
|
-
parse:
|
|
1477
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1478
|
-
[Symbol.iterator]: () =>
|
|
1592
|
+
ZERO: Ut,
|
|
1593
|
+
create: vt,
|
|
1594
|
+
parse: Z
|
|
1595
|
+
}, Symbol.toStringTag, { value: "Module" })), B = -1, F = {
|
|
1596
|
+
[Symbol.iterator]: () => F,
|
|
1479
1597
|
next: () => ({ done: !0, value: void 0 })
|
|
1480
|
-
},
|
|
1481
|
-
(
|
|
1482
|
-
atob(
|
|
1598
|
+
}, At = o.string().transform(
|
|
1599
|
+
(a) => new Uint8Array(
|
|
1600
|
+
atob(a).split("").map((t) => t.charCodeAt(0))
|
|
1483
1601
|
).buffer
|
|
1484
|
-
),
|
|
1485
|
-
if (
|
|
1602
|
+
), Mt = o.union([o.null(), o.undefined()]).transform(() => new Uint8Array().buffer), Y = 10, tt = (a, t) => {
|
|
1603
|
+
if (a === "number" && !t.isNumeric)
|
|
1486
1604
|
throw new Error(`cannot convert series of type ${t.toString()} to number`);
|
|
1487
|
-
if (
|
|
1605
|
+
if (a === "bigint" && !t.usesBigInt)
|
|
1488
1606
|
throw new Error(`cannot convert series of type ${t.toString()} to bigint`);
|
|
1489
|
-
},
|
|
1490
|
-
class
|
|
1607
|
+
}, et = "sy_x_telem_series";
|
|
1608
|
+
class v {
|
|
1491
1609
|
/**
|
|
1492
1610
|
* A unique identifier for the series. If specified by the user, it is their
|
|
1493
1611
|
* responsibility to ensure that it is unique. If not specified, a new ID will be
|
|
@@ -1498,7 +1616,7 @@ class I {
|
|
|
1498
1616
|
* A discriminator used for identifying instances of the series class even
|
|
1499
1617
|
* when bundlers mangle the class name.
|
|
1500
1618
|
*/
|
|
1501
|
-
discriminator =
|
|
1619
|
+
discriminator = et;
|
|
1502
1620
|
/** The data type of the series. */
|
|
1503
1621
|
dataType;
|
|
1504
1622
|
/**
|
|
@@ -1514,18 +1632,24 @@ class I {
|
|
|
1514
1632
|
/** The underlying data. */
|
|
1515
1633
|
_data;
|
|
1516
1634
|
/** The time range occupied by the series' data. */
|
|
1517
|
-
timeRange =
|
|
1635
|
+
timeRange = O.ZERO;
|
|
1518
1636
|
/**
|
|
1519
1637
|
* Alignment defines the location of the series relative to other series in a logical
|
|
1520
1638
|
* group. Useful for defining the position of the series within a channel's data.
|
|
1521
1639
|
*/
|
|
1522
1640
|
alignment = 0n;
|
|
1641
|
+
/**
|
|
1642
|
+
* Alignment multiple defines the number of alignment steps taken per sample. This is
|
|
1643
|
+
* useful for when the samples in a series represent a partial view of the raw data
|
|
1644
|
+
* i.e. decimation or averaging.
|
|
1645
|
+
*/
|
|
1646
|
+
alignmentMultiple = 1n;
|
|
1523
1647
|
/** A cached minimum value. */
|
|
1524
1648
|
cachedMin;
|
|
1525
1649
|
/** A cached maximum value. */
|
|
1526
1650
|
cachedMax;
|
|
1527
1651
|
/** The write position of the buffer. */
|
|
1528
|
-
writePos =
|
|
1652
|
+
writePos = B;
|
|
1529
1653
|
/** Tracks the number of entities currently using this array. */
|
|
1530
1654
|
_refCount = 0;
|
|
1531
1655
|
/** Caches the length of the array for variable length data types. */
|
|
@@ -1537,22 +1661,22 @@ class I {
|
|
|
1537
1661
|
* can be constructed into a series.
|
|
1538
1662
|
*/
|
|
1539
1663
|
static crudeZ = o.object({
|
|
1540
|
-
timeRange:
|
|
1541
|
-
dataType:
|
|
1664
|
+
timeRange: O.z.optional(),
|
|
1665
|
+
dataType: n.z,
|
|
1542
1666
|
alignment: o.coerce.bigint().optional(),
|
|
1543
1667
|
data: o.union([
|
|
1544
|
-
|
|
1545
|
-
|
|
1668
|
+
At,
|
|
1669
|
+
Mt,
|
|
1546
1670
|
o.instanceof(ArrayBuffer),
|
|
1547
1671
|
o.instanceof(Uint8Array)
|
|
1548
1672
|
]),
|
|
1549
|
-
glBufferUsage:
|
|
1673
|
+
glBufferUsage: ht.optional().default("static").optional()
|
|
1550
1674
|
});
|
|
1551
1675
|
/**
|
|
1552
1676
|
* A zod schema that validates and constructs a series from it's crude
|
|
1553
1677
|
* representation.
|
|
1554
1678
|
*/
|
|
1555
|
-
static z =
|
|
1679
|
+
static z = v.crudeZ.transform((t) => new v(t));
|
|
1556
1680
|
/**
|
|
1557
1681
|
* The Series constructor accepts either a SeriesArgs object or a CrudeSeries value.
|
|
1558
1682
|
*
|
|
@@ -1627,73 +1751,74 @@ class I {
|
|
|
1627
1751
|
* @throws Error if data type cannot be inferred from input
|
|
1628
1752
|
*/
|
|
1629
1753
|
constructor(t) {
|
|
1630
|
-
|
|
1754
|
+
Et(t) && (t = { data: t }), t.data ??= [];
|
|
1631
1755
|
const {
|
|
1632
1756
|
dataType: e,
|
|
1633
1757
|
timeRange: s,
|
|
1634
1758
|
sampleOffset: u = 0,
|
|
1635
|
-
glBufferUsage:
|
|
1636
|
-
alignment:
|
|
1637
|
-
|
|
1759
|
+
glBufferUsage: l = "static",
|
|
1760
|
+
alignment: h = 0n,
|
|
1761
|
+
alignmentMultiple: U = 1n,
|
|
1762
|
+
key: y = X(),
|
|
1638
1763
|
data: g
|
|
1639
1764
|
} = t;
|
|
1640
|
-
if (
|
|
1641
|
-
const
|
|
1642
|
-
this.key =
|
|
1765
|
+
if (st(g)) {
|
|
1766
|
+
const f = g;
|
|
1767
|
+
this.key = f.key, this.dataType = f.dataType, this.sampleOffset = f.sampleOffset, this.gl = f.gl, this._data = f._data, this.timeRange = f.timeRange, this.alignment = f.alignment, this.alignmentMultiple = f.alignmentMultiple, this.cachedMin = f.cachedMin, this.cachedMax = f.cachedMax, this.writePos = f.writePos, this._refCount = f._refCount, this.cachedLength = f.cachedLength;
|
|
1643
1768
|
return;
|
|
1644
1769
|
}
|
|
1645
|
-
const
|
|
1646
|
-
if (e != null) this.dataType = new
|
|
1770
|
+
const m = z(g), b = Array.isArray(g);
|
|
1771
|
+
if (e != null) this.dataType = new n(e);
|
|
1647
1772
|
else {
|
|
1648
1773
|
if (g instanceof ArrayBuffer)
|
|
1649
1774
|
throw new Error(
|
|
1650
1775
|
"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
|
|
1651
1776
|
);
|
|
1652
|
-
if (
|
|
1653
|
-
let
|
|
1654
|
-
if (!
|
|
1777
|
+
if (b || m) {
|
|
1778
|
+
let f = g;
|
|
1779
|
+
if (!m) {
|
|
1655
1780
|
if (g.length === 0)
|
|
1656
1781
|
throw new Error(
|
|
1657
1782
|
"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
|
|
1658
1783
|
);
|
|
1659
|
-
|
|
1784
|
+
f = g[0];
|
|
1660
1785
|
}
|
|
1661
|
-
if (typeof
|
|
1662
|
-
else if (typeof
|
|
1663
|
-
else if (typeof
|
|
1664
|
-
else if (typeof
|
|
1665
|
-
else if (
|
|
1666
|
-
this.dataType =
|
|
1667
|
-
else if (typeof
|
|
1786
|
+
if (typeof f == "string") this.dataType = n.STRING;
|
|
1787
|
+
else if (typeof f == "number") this.dataType = n.FLOAT64;
|
|
1788
|
+
else if (typeof f == "bigint") this.dataType = n.INT64;
|
|
1789
|
+
else if (typeof f == "boolean") this.dataType = n.BOOLEAN;
|
|
1790
|
+
else if (f instanceof r || f instanceof Date || f instanceof r)
|
|
1791
|
+
this.dataType = n.TIMESTAMP;
|
|
1792
|
+
else if (typeof f == "object") this.dataType = n.JSON;
|
|
1668
1793
|
else
|
|
1669
1794
|
throw new Error(
|
|
1670
|
-
`cannot infer data type of ${typeof
|
|
1795
|
+
`cannot infer data type of ${typeof f} when constructing a Series from a JS array`
|
|
1671
1796
|
);
|
|
1672
|
-
} else this.dataType = new
|
|
1797
|
+
} else this.dataType = new n(g);
|
|
1673
1798
|
}
|
|
1674
|
-
if (!
|
|
1675
|
-
else if (
|
|
1799
|
+
if (!b && !m) this._data = g;
|
|
1800
|
+
else if (b && g.length === 0)
|
|
1676
1801
|
this._data = new this.dataType.Array([]).buffer;
|
|
1677
1802
|
else {
|
|
1678
|
-
let
|
|
1679
|
-
const
|
|
1680
|
-
(
|
|
1803
|
+
let f = m ? [g] : g;
|
|
1804
|
+
const A = f[0];
|
|
1805
|
+
(A instanceof r || A instanceof Date || A instanceof i) && (f = f.map((M) => new r(M).valueOf())), this.dataType.equals(n.STRING) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
|
|
1681
1806
|
`)}
|
|
1682
|
-
`).buffer) : this.dataType.equals(
|
|
1683
|
-
`${
|
|
1807
|
+
`).buffer) : this.dataType.equals(n.JSON) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(
|
|
1808
|
+
`${f.map((M) => $.encodeString(M)).join(`
|
|
1684
1809
|
`)}
|
|
1685
1810
|
`
|
|
1686
|
-
).buffer) : this.dataType.usesBigInt && typeof
|
|
1687
|
-
|
|
1688
|
-
).buffer : !this.dataType.usesBigInt && typeof
|
|
1689
|
-
|
|
1690
|
-
).buffer : this._data = new this.dataType.Array(
|
|
1811
|
+
).buffer) : this.dataType.usesBigInt && typeof A == "number" ? this._data = new this.dataType.Array(
|
|
1812
|
+
f.map((M) => BigInt(Math.round(M)))
|
|
1813
|
+
).buffer : !this.dataType.usesBigInt && typeof A == "bigint" ? this._data = new this.dataType.Array(
|
|
1814
|
+
f.map(Number)
|
|
1815
|
+
).buffer : this._data = new this.dataType.Array(f).buffer;
|
|
1691
1816
|
}
|
|
1692
|
-
this.key = y, this.alignment =
|
|
1817
|
+
this.key = y, this.alignment = h, this.alignmentMultiple = U, this.sampleOffset = u ?? 0, this.timeRange = s ?? O.ZERO, this.gl = {
|
|
1693
1818
|
control: null,
|
|
1694
1819
|
buffer: null,
|
|
1695
1820
|
prevBuffer: 0,
|
|
1696
|
-
bufferUsage:
|
|
1821
|
+
bufferUsage: l
|
|
1697
1822
|
};
|
|
1698
1823
|
}
|
|
1699
1824
|
/**
|
|
@@ -1706,8 +1831,8 @@ class I {
|
|
|
1706
1831
|
static alloc({ capacity: t, dataType: e, ...s }) {
|
|
1707
1832
|
if (t === 0)
|
|
1708
1833
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
1709
|
-
const u = new new
|
|
1710
|
-
return
|
|
1834
|
+
const u = new new n(e).Array(t), l = new v({ data: u.buffer, dataType: e, ...s });
|
|
1835
|
+
return l.writePos = 0, l;
|
|
1711
1836
|
}
|
|
1712
1837
|
/**
|
|
1713
1838
|
* @returns the number of references to this series i.e. the number of times this
|
|
@@ -1749,12 +1874,12 @@ class I {
|
|
|
1749
1874
|
return this.dataType.isVariable ? this.writeVariable(t) : this.writeFixed(t);
|
|
1750
1875
|
}
|
|
1751
1876
|
writeVariable(t) {
|
|
1752
|
-
if (this.writePos ===
|
|
1877
|
+
if (this.writePos === B) return 0;
|
|
1753
1878
|
const e = this.byteCapacity.valueOf() - this.writePos, s = t.subBytes(0, e);
|
|
1754
1879
|
return this.writeToUnderlyingData(s), this.writePos += s.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += s.length, this.calculateCachedLength()), s.length;
|
|
1755
1880
|
}
|
|
1756
1881
|
writeFixed(t) {
|
|
1757
|
-
if (this.writePos ===
|
|
1882
|
+
if (this.writePos === B) return 0;
|
|
1758
1883
|
const e = this.capacity - this.writePos, s = t.sub(0, e);
|
|
1759
1884
|
return this.writeToUnderlyingData(s), this.cachedLength = void 0, this.maybeRecomputeMinMax(s), this.writePos += s.length, s.length;
|
|
1760
1885
|
}
|
|
@@ -1777,7 +1902,7 @@ class I {
|
|
|
1777
1902
|
* @returns A typed array containing the series data.
|
|
1778
1903
|
*/
|
|
1779
1904
|
get data() {
|
|
1780
|
-
return this.writePos ===
|
|
1905
|
+
return this.writePos === B ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
|
|
1781
1906
|
}
|
|
1782
1907
|
/**
|
|
1783
1908
|
* Returns an array of the values in the series as strings.
|
|
@@ -1796,16 +1921,16 @@ class I {
|
|
|
1796
1921
|
* @returns An array of values parsed from the JSON series.
|
|
1797
1922
|
*/
|
|
1798
1923
|
parseJSON(t) {
|
|
1799
|
-
if (!this.dataType.equals(
|
|
1924
|
+
if (!this.dataType.equals(n.JSON))
|
|
1800
1925
|
throw new Error("cannot parse non-JSON series as JSON");
|
|
1801
|
-
return this.toStrings().map((e) => t.parse(
|
|
1926
|
+
return this.toStrings().map((e) => t.parse($.decodeString(e)));
|
|
1802
1927
|
}
|
|
1803
1928
|
/**
|
|
1804
1929
|
* Returns the capacity of the series in bytes.
|
|
1805
1930
|
* @returns The size of the underlying buffer in bytes.
|
|
1806
1931
|
*/
|
|
1807
1932
|
get byteCapacity() {
|
|
1808
|
-
return new
|
|
1933
|
+
return new c(this.underlyingData.byteLength);
|
|
1809
1934
|
}
|
|
1810
1935
|
/**
|
|
1811
1936
|
* Returns the capacity of the series in samples.
|
|
@@ -1821,7 +1946,7 @@ class I {
|
|
|
1821
1946
|
* @returns The size of the data in bytes.
|
|
1822
1947
|
*/
|
|
1823
1948
|
get byteLength() {
|
|
1824
|
-
return this.writePos ===
|
|
1949
|
+
return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new c(this.writePos) : this.dataType.density.size(this.writePos);
|
|
1825
1950
|
}
|
|
1826
1951
|
/**
|
|
1827
1952
|
* Returns the number of samples in this array.
|
|
@@ -1829,7 +1954,7 @@ class I {
|
|
|
1829
1954
|
* @returns The number of samples in the series.
|
|
1830
1955
|
*/
|
|
1831
1956
|
get length() {
|
|
1832
|
-
return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos ===
|
|
1957
|
+
return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === B ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
|
|
1833
1958
|
}
|
|
1834
1959
|
calculateCachedLength() {
|
|
1835
1960
|
if (!this.dataType.isVariable)
|
|
@@ -1837,7 +1962,7 @@ class I {
|
|
|
1837
1962
|
let t = 0;
|
|
1838
1963
|
const e = [0];
|
|
1839
1964
|
return this.data.forEach((s, u) => {
|
|
1840
|
-
s ===
|
|
1965
|
+
s === Y && (t++, e.push(u + 1));
|
|
1841
1966
|
}), this._cachedIndexes = e, this.cachedLength = t, t;
|
|
1842
1967
|
}
|
|
1843
1968
|
/**
|
|
@@ -1853,8 +1978,8 @@ class I {
|
|
|
1853
1978
|
if (this.dataType.equals(t)) return this;
|
|
1854
1979
|
const s = new t.Array(this.length);
|
|
1855
1980
|
for (let u = 0; u < this.length; u++)
|
|
1856
|
-
s[u] =
|
|
1857
|
-
return new
|
|
1981
|
+
s[u] = dt(this.dataType, t, this.data[u], e);
|
|
1982
|
+
return new v({
|
|
1858
1983
|
data: s.buffer,
|
|
1859
1984
|
dataType: t,
|
|
1860
1985
|
timeRange: this.timeRange,
|
|
@@ -1865,7 +1990,7 @@ class I {
|
|
|
1865
1990
|
}
|
|
1866
1991
|
calcRawMax() {
|
|
1867
1992
|
if (this.length === 0) return -1 / 0;
|
|
1868
|
-
if (this.dataType.equals(
|
|
1993
|
+
if (this.dataType.equals(n.TIMESTAMP))
|
|
1869
1994
|
this.cachedMax = this.data[this.data.length - 1];
|
|
1870
1995
|
else if (this.dataType.usesBigInt) {
|
|
1871
1996
|
const t = this.data;
|
|
@@ -1883,11 +2008,11 @@ class I {
|
|
|
1883
2008
|
calcMax() {
|
|
1884
2009
|
if (this.dataType.isVariable)
|
|
1885
2010
|
throw new Error("cannot calculate maximum on a variable length data type");
|
|
1886
|
-
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(),
|
|
2011
|
+
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), T(this.cachedMax, this.sampleOffset));
|
|
1887
2012
|
}
|
|
1888
2013
|
calcRawMin() {
|
|
1889
2014
|
if (this.length === 0) return 1 / 0;
|
|
1890
|
-
if (this.dataType.equals(
|
|
2015
|
+
if (this.dataType.equals(n.TIMESTAMP)) this.cachedMin = this.data[0];
|
|
1891
2016
|
else if (this.dataType.usesBigInt) {
|
|
1892
2017
|
const t = this.data;
|
|
1893
2018
|
this.cachedMin = t.reduce((e, s) => e < s ? e : s);
|
|
@@ -1904,11 +2029,11 @@ class I {
|
|
|
1904
2029
|
calcMin() {
|
|
1905
2030
|
if (this.dataType.isVariable)
|
|
1906
2031
|
throw new Error("cannot calculate minimum on a variable length data type");
|
|
1907
|
-
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(),
|
|
2032
|
+
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), T(this.cachedMin, this.sampleOffset));
|
|
1908
2033
|
}
|
|
1909
2034
|
/** @returns the bounds of the series. */
|
|
1910
2035
|
get bounds() {
|
|
1911
|
-
return
|
|
2036
|
+
return x(Number(this.min), Number(this.max), { makeValid: !1 });
|
|
1912
2037
|
}
|
|
1913
2038
|
maybeRecomputeMinMax(t) {
|
|
1914
2039
|
if (this.cachedMin != null) {
|
|
@@ -1921,7 +2046,7 @@ class I {
|
|
|
1921
2046
|
}
|
|
1922
2047
|
}
|
|
1923
2048
|
atAlignment(t, e) {
|
|
1924
|
-
const s = Number(t - this.alignment);
|
|
2049
|
+
const s = Number((t - this.alignment) / this.alignmentMultiple);
|
|
1925
2050
|
if (s < 0 || s >= this.length) {
|
|
1926
2051
|
if (e === !0) throw new Error(`[series] - no value at index ${s}`);
|
|
1927
2052
|
return;
|
|
@@ -1930,18 +2055,18 @@ class I {
|
|
|
1930
2055
|
}
|
|
1931
2056
|
at(t, e = !1) {
|
|
1932
2057
|
if (this.dataType.isVariable) return this.atVariable(t, e ?? !1);
|
|
1933
|
-
if (this.dataType.equals(
|
|
2058
|
+
if (this.dataType.equals(n.UUID)) return this.atUUID(t, e);
|
|
1934
2059
|
t < 0 && (t = this.length + t);
|
|
1935
2060
|
const s = this.data[t];
|
|
1936
2061
|
if (s == null) {
|
|
1937
2062
|
if (e === !0) throw new Error(`[series] - no value at index ${t}`);
|
|
1938
2063
|
return;
|
|
1939
2064
|
}
|
|
1940
|
-
return
|
|
2065
|
+
return T(s, this.sampleOffset);
|
|
1941
2066
|
}
|
|
1942
2067
|
atUUID(t, e) {
|
|
1943
2068
|
t < 0 && (t = this.length + t);
|
|
1944
|
-
const s =
|
|
2069
|
+
const s = Z(
|
|
1945
2070
|
new Uint8Array(this.buffer, t * this.dataType.density.valueOf())
|
|
1946
2071
|
);
|
|
1947
2072
|
if (s == null) {
|
|
@@ -1956,21 +2081,21 @@ class I {
|
|
|
1956
2081
|
s = this._cachedIndexes[t], u = this._cachedIndexes[t + 1] - 1;
|
|
1957
2082
|
else {
|
|
1958
2083
|
t < 0 && (t = this.length + t);
|
|
1959
|
-
for (let
|
|
1960
|
-
if (this.data[
|
|
2084
|
+
for (let h = 0; h < this.data.length; h++)
|
|
2085
|
+
if (this.data[h] === Y) {
|
|
1961
2086
|
if (t === 0) {
|
|
1962
|
-
u =
|
|
2087
|
+
u = h;
|
|
1963
2088
|
break;
|
|
1964
2089
|
}
|
|
1965
|
-
s =
|
|
2090
|
+
s = h + 1, t--;
|
|
1966
2091
|
}
|
|
1967
2092
|
if (u === 0 && (u = this.data.length), s >= u || t > 0) {
|
|
1968
2093
|
if (e) throw new Error(`[series] - no value at index ${t}`);
|
|
1969
2094
|
return;
|
|
1970
2095
|
}
|
|
1971
2096
|
}
|
|
1972
|
-
const
|
|
1973
|
-
return this.dataType.equals(
|
|
2097
|
+
const l = this.data.slice(s, u);
|
|
2098
|
+
return this.dataType.equals(n.STRING) ? new TextDecoder().decode(l) : nt(JSON.parse(new TextDecoder().decode(l)));
|
|
1974
2099
|
}
|
|
1975
2100
|
/**
|
|
1976
2101
|
* @returns the index of the first sample that is greater than or equal to the given value.
|
|
@@ -1979,11 +2104,11 @@ class I {
|
|
|
1979
2104
|
*/
|
|
1980
2105
|
binarySearch(t) {
|
|
1981
2106
|
let e = 0, s = this.length - 1;
|
|
1982
|
-
const u =
|
|
2107
|
+
const u = rt(t);
|
|
1983
2108
|
for (; e <= s; ) {
|
|
1984
|
-
const
|
|
1985
|
-
if (
|
|
1986
|
-
|
|
2109
|
+
const l = Math.floor((e + s) / 2), h = u(this.at(l, !0), t);
|
|
2110
|
+
if (h === 0) return l;
|
|
2111
|
+
h < 0 ? e = l + 1 : s = l - 1;
|
|
1987
2112
|
}
|
|
1988
2113
|
return e;
|
|
1989
2114
|
}
|
|
@@ -1995,23 +2120,23 @@ class I {
|
|
|
1995
2120
|
* be the same buffer previously passed to {@method acquire} or {@method updateGLBuffer}.
|
|
1996
2121
|
*/
|
|
1997
2122
|
updateGLBuffer(t) {
|
|
1998
|
-
if (this.gl.control = t, !this.dataType.equals(
|
|
2123
|
+
if (this.gl.control = t, !this.dataType.equals(n.FLOAT32) && !this.dataType.equals(n.UINT8))
|
|
1999
2124
|
throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
|
|
2000
2125
|
const { buffer: e, bufferUsage: s, prevBuffer: u } = this.gl;
|
|
2001
2126
|
if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== u)
|
|
2002
|
-
if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !==
|
|
2127
|
+
if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !== B) {
|
|
2003
2128
|
u === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
|
|
2004
|
-
const
|
|
2005
|
-
t.bufferSubData(t.ARRAY_BUFFER,
|
|
2129
|
+
const l = this.dataType.density.size(u).valueOf(), h = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
|
|
2130
|
+
t.bufferSubData(t.ARRAY_BUFFER, l, h.buffer), this.gl.prevBuffer = this.writePos;
|
|
2006
2131
|
} else
|
|
2007
2132
|
t.bufferData(
|
|
2008
2133
|
t.ARRAY_BUFFER,
|
|
2009
2134
|
this.buffer,
|
|
2010
2135
|
s === "static" ? t.STATIC_DRAW : t.DYNAMIC_DRAW
|
|
2011
|
-
), this.gl.prevBuffer =
|
|
2136
|
+
), this.gl.prevBuffer = B;
|
|
2012
2137
|
}
|
|
2013
2138
|
as(t) {
|
|
2014
|
-
return
|
|
2139
|
+
return tt(t, this.dataType), this;
|
|
2015
2140
|
}
|
|
2016
2141
|
/** @returns a digest containing information about the series. */
|
|
2017
2142
|
get digest() {
|
|
@@ -2020,8 +2145,8 @@ class I {
|
|
|
2020
2145
|
dataType: this.dataType.toString(),
|
|
2021
2146
|
sampleOffset: this.sampleOffset,
|
|
2022
2147
|
alignment: {
|
|
2023
|
-
lower:
|
|
2024
|
-
upper:
|
|
2148
|
+
lower: j(this.alignmentBounds.lower),
|
|
2149
|
+
upper: j(this.alignmentBounds.upper)
|
|
2025
2150
|
},
|
|
2026
2151
|
timeRange: this.timeRange.toString(),
|
|
2027
2152
|
length: this.length,
|
|
@@ -2038,7 +2163,10 @@ class I {
|
|
|
2038
2163
|
* is exclusive.
|
|
2039
2164
|
*/
|
|
2040
2165
|
get alignmentBounds() {
|
|
2041
|
-
return
|
|
2166
|
+
return x(
|
|
2167
|
+
this.alignment,
|
|
2168
|
+
this.alignment + BigInt(this.length) * this.alignmentMultiple
|
|
2169
|
+
);
|
|
2042
2170
|
}
|
|
2043
2171
|
maybeGarbageCollectGLBuffer(t) {
|
|
2044
2172
|
this.gl.buffer != null && (t.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
|
|
@@ -2055,10 +2183,10 @@ class I {
|
|
|
2055
2183
|
}
|
|
2056
2184
|
[Symbol.iterator]() {
|
|
2057
2185
|
if (this.dataType.isVariable) {
|
|
2058
|
-
const t = new
|
|
2059
|
-
return this.dataType.equals(
|
|
2186
|
+
const t = new Bt(this);
|
|
2187
|
+
return this.dataType.equals(n.JSON) ? new V(t) : t;
|
|
2060
2188
|
}
|
|
2061
|
-
return this.dataType.equals(
|
|
2189
|
+
return this.dataType.equals(n.UUID) ? new Ct(this) : new xt(this);
|
|
2062
2190
|
}
|
|
2063
2191
|
/**
|
|
2064
2192
|
* Returns a slice of the series from start to end.
|
|
@@ -2085,7 +2213,7 @@ class I {
|
|
|
2085
2213
|
* @returns An iterator over the specified range.
|
|
2086
2214
|
*/
|
|
2087
2215
|
subIterator(t, e) {
|
|
2088
|
-
return new
|
|
2216
|
+
return new J(this, t, e ?? this.length);
|
|
2089
2217
|
}
|
|
2090
2218
|
/**
|
|
2091
2219
|
* Returns an iterator over a portion of the series based on alignment.
|
|
@@ -2094,16 +2222,17 @@ class I {
|
|
|
2094
2222
|
* @returns An iterator over the specified alignment range.
|
|
2095
2223
|
*/
|
|
2096
2224
|
subAlignmentIterator(t, e) {
|
|
2097
|
-
|
|
2098
|
-
this
|
|
2099
|
-
|
|
2100
|
-
Number(e - this.alignment)
|
|
2225
|
+
const s = Math.ceil(
|
|
2226
|
+
Number(t - this.alignment) / Number(this.alignmentMultiple)
|
|
2227
|
+
), u = Math.ceil(
|
|
2228
|
+
Number(e - this.alignment) / Number(this.alignmentMultiple)
|
|
2101
2229
|
);
|
|
2230
|
+
return new J(this, s, u);
|
|
2102
2231
|
}
|
|
2103
2232
|
subBytes(t, e) {
|
|
2104
2233
|
if (t >= 0 && (e == null || e >= this.byteLength.valueOf())) return this;
|
|
2105
2234
|
const s = this.data.subarray(t, e);
|
|
2106
|
-
return new
|
|
2235
|
+
return new v({
|
|
2107
2236
|
data: s,
|
|
2108
2237
|
dataType: this.dataType,
|
|
2109
2238
|
timeRange: this.timeRange,
|
|
@@ -2115,7 +2244,7 @@ class I {
|
|
|
2115
2244
|
sliceSub(t, e, s) {
|
|
2116
2245
|
if (e <= 0 && (s == null || s >= this.length)) return this;
|
|
2117
2246
|
let u;
|
|
2118
|
-
return t ? u = this.data.subarray(e, s) : u = this.data.slice(e, s), new
|
|
2247
|
+
return t ? u = this.data.subarray(e, s) : u = this.data.slice(e, s), new v({
|
|
2119
2248
|
data: u,
|
|
2120
2249
|
dataType: this.dataType,
|
|
2121
2250
|
timeRange: this.timeRange,
|
|
@@ -2130,10 +2259,10 @@ class I {
|
|
|
2130
2259
|
* @returns A new series with the specified alignment.
|
|
2131
2260
|
*/
|
|
2132
2261
|
reAlign(t) {
|
|
2133
|
-
return new
|
|
2262
|
+
return new v({
|
|
2134
2263
|
data: this.buffer,
|
|
2135
2264
|
dataType: this.dataType,
|
|
2136
|
-
timeRange:
|
|
2265
|
+
timeRange: O.ZERO,
|
|
2137
2266
|
sampleOffset: this.sampleOffset,
|
|
2138
2267
|
glBufferUsage: "static",
|
|
2139
2268
|
alignment: t
|
|
@@ -2157,21 +2286,21 @@ class I {
|
|
|
2157
2286
|
return t += "])", t;
|
|
2158
2287
|
}
|
|
2159
2288
|
}
|
|
2160
|
-
const
|
|
2161
|
-
class
|
|
2289
|
+
const Et = (a) => a == null ? !1 : Array.isArray(a) || a instanceof ArrayBuffer || ArrayBuffer.isView(a) && !(a instanceof DataView) || a instanceof v ? !0 : z(a), st = D(et, v);
|
|
2290
|
+
class J {
|
|
2162
2291
|
series;
|
|
2163
2292
|
end;
|
|
2164
2293
|
index;
|
|
2165
2294
|
constructor(t, e, s) {
|
|
2166
2295
|
this.series = t;
|
|
2167
|
-
const u =
|
|
2168
|
-
this.end =
|
|
2296
|
+
const u = x(0, t.length + 1);
|
|
2297
|
+
this.end = k(u, s), this.index = k(u, e);
|
|
2169
2298
|
}
|
|
2170
2299
|
next() {
|
|
2171
2300
|
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
2172
2301
|
}
|
|
2173
2302
|
}
|
|
2174
|
-
class
|
|
2303
|
+
class Bt {
|
|
2175
2304
|
series;
|
|
2176
2305
|
index;
|
|
2177
2306
|
decoder;
|
|
@@ -2184,12 +2313,12 @@ class vt {
|
|
|
2184
2313
|
}
|
|
2185
2314
|
next() {
|
|
2186
2315
|
const t = this.index, e = this.series.data;
|
|
2187
|
-
for (; this.index < e.length && e[this.index] !==
|
|
2316
|
+
for (; this.index < e.length && e[this.index] !== Y; ) this.index++;
|
|
2188
2317
|
const s = this.index;
|
|
2189
2318
|
return t === s ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(t, s)) });
|
|
2190
2319
|
}
|
|
2191
2320
|
}
|
|
2192
|
-
class
|
|
2321
|
+
class V {
|
|
2193
2322
|
wrapped;
|
|
2194
2323
|
static schema = o.record(o.string(), o.unknown());
|
|
2195
2324
|
constructor(t) {
|
|
@@ -2199,27 +2328,27 @@ class $ {
|
|
|
2199
2328
|
const t = this.wrapped.next();
|
|
2200
2329
|
return t.done === !0 ? { done: !0, value: void 0 } : {
|
|
2201
2330
|
done: !1,
|
|
2202
|
-
value:
|
|
2331
|
+
value: $.decodeString(t.value, V.schema)
|
|
2203
2332
|
};
|
|
2204
2333
|
}
|
|
2205
2334
|
}
|
|
2206
|
-
class
|
|
2335
|
+
class Ct {
|
|
2207
2336
|
series;
|
|
2208
2337
|
index;
|
|
2209
2338
|
data;
|
|
2210
2339
|
density;
|
|
2211
2340
|
constructor(t) {
|
|
2212
|
-
if (!t.dataType.equals(
|
|
2341
|
+
if (!t.dataType.equals(n.UUID))
|
|
2213
2342
|
throw new Error("cannot create a UUID series iterator for a non-UUID series");
|
|
2214
|
-
this.series = t, this.index = 0, this.data = new Uint8Array(t.buffer), this.density =
|
|
2343
|
+
this.series = t, this.index = 0, this.data = new Uint8Array(t.buffer), this.density = n.UUID.density.valueOf();
|
|
2215
2344
|
}
|
|
2216
2345
|
next() {
|
|
2217
2346
|
if (this.index >= this.series.length) return { done: !0, value: void 0 };
|
|
2218
|
-
const t =
|
|
2347
|
+
const t = Z(this.data, this.index * this.density);
|
|
2219
2348
|
return this.index++, { done: !1, value: t };
|
|
2220
2349
|
}
|
|
2221
2350
|
}
|
|
2222
|
-
class
|
|
2351
|
+
class xt {
|
|
2223
2352
|
series;
|
|
2224
2353
|
index;
|
|
2225
2354
|
constructor(t) {
|
|
@@ -2232,7 +2361,7 @@ class At {
|
|
|
2232
2361
|
};
|
|
2233
2362
|
}
|
|
2234
2363
|
}
|
|
2235
|
-
class
|
|
2364
|
+
class Wt {
|
|
2236
2365
|
/** The array of series in this collection */
|
|
2237
2366
|
series;
|
|
2238
2367
|
/**
|
|
@@ -2285,14 +2414,14 @@ class Vt {
|
|
|
2285
2414
|
this.series = t;
|
|
2286
2415
|
}
|
|
2287
2416
|
as(t) {
|
|
2288
|
-
return
|
|
2417
|
+
return tt(t, this.dataType), this;
|
|
2289
2418
|
}
|
|
2290
2419
|
/**
|
|
2291
2420
|
* Returns the data type of the series in this collection. If the collection is empty,
|
|
2292
2421
|
* returns DataType.UNKNOWN.
|
|
2293
2422
|
*/
|
|
2294
2423
|
get dataType() {
|
|
2295
|
-
return this.series.length === 0 ?
|
|
2424
|
+
return this.series.length === 0 ? n.UNKNOWN : this.series[0].dataType;
|
|
2296
2425
|
}
|
|
2297
2426
|
/**
|
|
2298
2427
|
* Returns the combined time range of all series in the collection. If the collection
|
|
@@ -2300,7 +2429,7 @@ class Vt {
|
|
|
2300
2429
|
* series to the end of the last series.
|
|
2301
2430
|
*/
|
|
2302
2431
|
get timeRange() {
|
|
2303
|
-
return this.series.length === 0 ?
|
|
2432
|
+
return this.series.length === 0 ? O.ZERO : new O(
|
|
2304
2433
|
this.series[0].timeRange.start,
|
|
2305
2434
|
this.series[this.series.length - 1].timeRange.end
|
|
2306
2435
|
);
|
|
@@ -2318,7 +2447,7 @@ class Vt {
|
|
|
2318
2447
|
* series + its length. If the collection is empty, returns bounds.construct(0n, 0n).
|
|
2319
2448
|
*/
|
|
2320
2449
|
get alignmentBounds() {
|
|
2321
|
-
return this.series.length === 0 ?
|
|
2450
|
+
return this.series.length === 0 ? x(0n, 0n) : x(
|
|
2322
2451
|
this.series[0].alignmentBounds.lower,
|
|
2323
2452
|
this.series[this.series.length - 1].alignmentBounds.upper
|
|
2324
2453
|
);
|
|
@@ -2327,7 +2456,7 @@ class Vt {
|
|
|
2327
2456
|
const e = () => new Error(
|
|
2328
2457
|
`cannot push a ${t.dataType.toString()} series to a ${this.dataType.toString()} multi-series`
|
|
2329
2458
|
), s = t.dataType.equals(this.dataType);
|
|
2330
|
-
if (
|
|
2459
|
+
if (st(t)) {
|
|
2331
2460
|
if (this.series.length !== 0 && !s) throw e();
|
|
2332
2461
|
this.series.push(t);
|
|
2333
2462
|
} else {
|
|
@@ -2364,7 +2493,7 @@ class Vt {
|
|
|
2364
2493
|
* @returns An iterator over the specified range.
|
|
2365
2494
|
*/
|
|
2366
2495
|
subIterator(t, e) {
|
|
2367
|
-
return new
|
|
2496
|
+
return new P(this, t, e ?? this.length);
|
|
2368
2497
|
}
|
|
2369
2498
|
/**
|
|
2370
2499
|
* Returns an iterator over a portion of the multi-series based on alignment.
|
|
@@ -2374,28 +2503,32 @@ class Vt {
|
|
|
2374
2503
|
*/
|
|
2375
2504
|
subAlignmentIterator(t, e) {
|
|
2376
2505
|
if (t >= this.alignmentBounds.upper || e <= this.alignmentBounds.lower)
|
|
2377
|
-
return
|
|
2506
|
+
return F;
|
|
2378
2507
|
let s = 0;
|
|
2379
|
-
for (let
|
|
2380
|
-
const
|
|
2381
|
-
if (t <
|
|
2382
|
-
if (t >=
|
|
2383
|
-
else if (R(
|
|
2384
|
-
s +=
|
|
2508
|
+
for (let l = 0; l < this.series.length; l++) {
|
|
2509
|
+
const h = this.series[l];
|
|
2510
|
+
if (t < h.alignment) break;
|
|
2511
|
+
if (t >= h.alignmentBounds.upper) s += h.length;
|
|
2512
|
+
else if (R(h.alignmentBounds, t)) {
|
|
2513
|
+
s += Math.ceil(
|
|
2514
|
+
Number(t - h.alignment) / Number(h.alignmentMultiple)
|
|
2515
|
+
);
|
|
2385
2516
|
break;
|
|
2386
2517
|
}
|
|
2387
2518
|
}
|
|
2388
2519
|
let u = 0;
|
|
2389
|
-
for (let
|
|
2390
|
-
const
|
|
2391
|
-
if (e <
|
|
2392
|
-
if (e >=
|
|
2393
|
-
else if (R(
|
|
2394
|
-
u +=
|
|
2520
|
+
for (let l = 0; l < this.series.length; l++) {
|
|
2521
|
+
const h = this.series[l];
|
|
2522
|
+
if (e < h.alignment) break;
|
|
2523
|
+
if (e >= h.alignmentBounds.upper) u += h.length;
|
|
2524
|
+
else if (R(h.alignmentBounds, e)) {
|
|
2525
|
+
u += Math.ceil(
|
|
2526
|
+
Number(e - h.alignment) / Number(h.alignmentMultiple)
|
|
2527
|
+
);
|
|
2395
2528
|
break;
|
|
2396
2529
|
}
|
|
2397
2530
|
}
|
|
2398
|
-
return new
|
|
2531
|
+
return new P(this, s, u);
|
|
2399
2532
|
}
|
|
2400
2533
|
/**
|
|
2401
2534
|
* Returns an iterator over the specified alignment range and span.
|
|
@@ -2404,19 +2537,19 @@ class Vt {
|
|
|
2404
2537
|
* @returns An iterator over the specified range.
|
|
2405
2538
|
*/
|
|
2406
2539
|
subAlignmentSpanIterator(t, e) {
|
|
2407
|
-
if (t >= this.alignmentBounds.upper) return
|
|
2540
|
+
if (t >= this.alignmentBounds.upper) return F;
|
|
2408
2541
|
e = Math.min(e, Number(this.distance(t, this.alignmentBounds.upper)));
|
|
2409
2542
|
let s = 0;
|
|
2410
2543
|
for (let u = 0; u < this.series.length; u++) {
|
|
2411
|
-
const
|
|
2412
|
-
if (t <
|
|
2413
|
-
if (t >=
|
|
2414
|
-
else if (R(
|
|
2415
|
-
s += Number(t -
|
|
2544
|
+
const l = this.series[u];
|
|
2545
|
+
if (t < l.alignment) break;
|
|
2546
|
+
if (t >= l.alignmentBounds.upper) s += l.length;
|
|
2547
|
+
else if (R(l.alignmentBounds, t)) {
|
|
2548
|
+
s += Number(t - l.alignment);
|
|
2416
2549
|
break;
|
|
2417
2550
|
}
|
|
2418
2551
|
}
|
|
2419
|
-
return new
|
|
2552
|
+
return new P(this, s, s + e);
|
|
2420
2553
|
}
|
|
2421
2554
|
/**
|
|
2422
2555
|
* Updates the WebGL buffer for all series in the collection.
|
|
@@ -2429,13 +2562,13 @@ class Vt {
|
|
|
2429
2562
|
* Returns the bounds containing the minimum and maximum values across all series.
|
|
2430
2563
|
*/
|
|
2431
2564
|
get bounds() {
|
|
2432
|
-
return
|
|
2565
|
+
return it(this.series.map((t) => t.bounds));
|
|
2433
2566
|
}
|
|
2434
2567
|
/**
|
|
2435
2568
|
* Returns the sum of the byte lengths of all series.
|
|
2436
2569
|
*/
|
|
2437
2570
|
get byteLength() {
|
|
2438
|
-
return new
|
|
2571
|
+
return new c(this.series.reduce((t, e) => t + e.byteLength.valueOf(), 0));
|
|
2439
2572
|
}
|
|
2440
2573
|
/**
|
|
2441
2574
|
* Returns a combined typed array containing all data from all series.
|
|
@@ -2456,7 +2589,7 @@ class Vt {
|
|
|
2456
2589
|
*/
|
|
2457
2590
|
traverseAlignment(t, e) {
|
|
2458
2591
|
const s = this.series.map((u) => u.alignmentBounds);
|
|
2459
|
-
return
|
|
2592
|
+
return at(s, t, e);
|
|
2460
2593
|
}
|
|
2461
2594
|
/**
|
|
2462
2595
|
* Acquires a reference to the WebGL buffer for all series.
|
|
@@ -2479,7 +2612,7 @@ class Vt {
|
|
|
2479
2612
|
*/
|
|
2480
2613
|
distance(t, e) {
|
|
2481
2614
|
const s = this.series.map((u) => u.alignmentBounds);
|
|
2482
|
-
return
|
|
2615
|
+
return ut(s, t, e);
|
|
2483
2616
|
}
|
|
2484
2617
|
/**
|
|
2485
2618
|
* Parses a JSON multi-series into an array of values using the provided zod schema.
|
|
@@ -2489,7 +2622,7 @@ class Vt {
|
|
|
2489
2622
|
* @returns An array of values parsed from the JSON series.
|
|
2490
2623
|
*/
|
|
2491
2624
|
parseJSON(t) {
|
|
2492
|
-
if (!this.dataType.equals(
|
|
2625
|
+
if (!this.dataType.equals(n.JSON))
|
|
2493
2626
|
throw new Error("cannot parse non-JSON series as JSON");
|
|
2494
2627
|
return this.series.flatMap((e) => e.parseJSON(t));
|
|
2495
2628
|
}
|
|
@@ -2502,7 +2635,7 @@ class Vt {
|
|
|
2502
2635
|
next() {
|
|
2503
2636
|
return { done: !0, value: void 0 };
|
|
2504
2637
|
}
|
|
2505
|
-
} : new
|
|
2638
|
+
} : new Rt(this.series);
|
|
2506
2639
|
}
|
|
2507
2640
|
/**
|
|
2508
2641
|
* Returns an array of the values in the multi-series as strings.
|
|
@@ -2513,7 +2646,7 @@ class Vt {
|
|
|
2513
2646
|
return this.series.flatMap((t) => t.toStrings());
|
|
2514
2647
|
}
|
|
2515
2648
|
}
|
|
2516
|
-
class
|
|
2649
|
+
class Rt {
|
|
2517
2650
|
series;
|
|
2518
2651
|
seriesIndex;
|
|
2519
2652
|
internal;
|
|
@@ -2528,7 +2661,7 @@ class Et {
|
|
|
2528
2661
|
return this;
|
|
2529
2662
|
}
|
|
2530
2663
|
}
|
|
2531
|
-
class
|
|
2664
|
+
class P {
|
|
2532
2665
|
series;
|
|
2533
2666
|
index;
|
|
2534
2667
|
end;
|
|
@@ -2542,27 +2675,27 @@ class S {
|
|
|
2542
2675
|
return this;
|
|
2543
2676
|
}
|
|
2544
2677
|
}
|
|
2545
|
-
const
|
|
2546
|
-
const t =
|
|
2678
|
+
const j = (a) => {
|
|
2679
|
+
const t = a >> 32n, e = a & 0xffffffffn;
|
|
2547
2680
|
return { domain: t, sample: e };
|
|
2548
2681
|
};
|
|
2549
2682
|
export {
|
|
2550
2683
|
d as D,
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
a,
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2684
|
+
Wt as M,
|
|
2685
|
+
I as R,
|
|
2686
|
+
v as S,
|
|
2687
|
+
r as T,
|
|
2688
|
+
i as a,
|
|
2689
|
+
O as b,
|
|
2690
|
+
n as c,
|
|
2691
|
+
c as d,
|
|
2692
|
+
z as e,
|
|
2693
|
+
dt as f,
|
|
2694
|
+
T as g,
|
|
2695
|
+
X as h,
|
|
2696
|
+
Et as i,
|
|
2697
|
+
kt as j,
|
|
2698
|
+
Gt as m,
|
|
2699
|
+
Jt as t,
|
|
2700
|
+
jt as u
|
|
2568
2701
|
};
|