@synnaxlabs/x 0.44.2 → 0.44.3
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 +15 -15
- package/dist/bounds-8OC_obRs.js +186 -0
- package/dist/bounds-CRK04jp7.cjs +1 -0
- package/dist/bounds.cjs +1 -1
- package/dist/bounds.js +1 -1
- package/dist/deep.cjs +1 -1
- package/dist/deep.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 +235 -229
- package/dist/{path-DVFrKaNI.js → path-Blh4wJuA.js} +24 -21
- package/dist/path-CPSfCjde.cjs +1 -0
- package/dist/{scale-C6qKDbRb.cjs → scale-C3fEtXxW.cjs} +1 -1
- package/dist/{scale-EWNUk-bn.js → scale-Db1Gunj0.js} +1 -1
- package/dist/scale.cjs +1 -1
- package/dist/scale.js +1 -1
- package/dist/series-BcF7A8Je.cjs +6 -0
- package/dist/{series-EA1uaEDj.js → series-Cl3Vh_u-.js} +588 -471
- package/dist/spatial.cjs +1 -1
- package/dist/spatial.js +2 -2
- 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/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 +78 -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/zod.cjs +1 -1
- package/dist/zod.js +1 -1
- package/package.json +3 -3
- 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/spatial/bounds/bounds.ts +1 -1
- 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 +556 -0
- package/src/telem/telem.ts +118 -5
- package/src/zod/util.ts +5 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/bounds-D6e9xoHt.cjs +0 -1
- package/dist/bounds-Dj9nG39I.js +0 -174
- package/dist/external-DsmsSN1Y.cjs +0 -1
- package/dist/path-BeMr8xWN.cjs +0 -1
- package/dist/series-CcA_WjbJ.cjs +0 -6
|
@@ -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
|
|
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 p, s as L, m as N, d as S, c as x, e as k, f as R, g as it, t as at, h as ut } from "./bounds-8OC_obRs.js";
|
|
6
6
|
import "./box-CO_2_DGG.js";
|
|
7
7
|
import "./dimensions-CRgergMS.js";
|
|
8
8
|
import "./base-DFq0vvGn.js";
|
|
9
9
|
import "./location-Ar5y2DX2.js";
|
|
10
|
-
import "./scale-
|
|
10
|
+
import "./scale-Db1Gunj0.js";
|
|
11
11
|
import "./xy-C_-hb3Q2.js";
|
|
12
|
-
let
|
|
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.
|
|
@@ -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(p(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(L(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(S(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(p(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(L(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(S(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(p(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(L(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(S(this.valueOf(), t));
|
|
894
978
|
}
|
|
895
979
|
/** Unknown/Invalid Density. */
|
|
896
980
|
static UNKNOWN = new d(0);
|
|
@@ -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.
|
|
@@ -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,13 +1109,13 @@ 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
1121
|
return t instanceof w ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
|
|
@@ -1053,19 +1137,19 @@ class w {
|
|
|
1053
1137
|
}
|
|
1054
1138
|
static max(...t) {
|
|
1055
1139
|
return new w(
|
|
1056
|
-
|
|
1057
|
-
|
|
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 w(
|
|
1145
|
+
static MAX = new w(r.MIN, r.MAX);
|
|
1062
1146
|
/** The minimum possible time range. */
|
|
1063
|
-
static MIN = new w(
|
|
1147
|
+
static MIN = new w(r.MAX, r.MIN);
|
|
1064
1148
|
/** A time range whose start and end are both zero. */
|
|
1065
|
-
static ZERO = new w(
|
|
1149
|
+
static ZERO = new w(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:
|
|
1152
|
+
o.object({ start: r.z, end: r.z }).transform((t) => new w(t.start, t.end)),
|
|
1069
1153
|
o.instanceof(w)
|
|
1070
1154
|
]);
|
|
1071
1155
|
/**
|
|
@@ -1080,15 +1164,15 @@ 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);
|
|
1084
1168
|
}
|
|
1085
1169
|
}
|
|
1086
|
-
class
|
|
1170
|
+
class n extends C {
|
|
1087
1171
|
constructor(t) {
|
|
1088
|
-
if (t instanceof
|
|
1172
|
+
if (t instanceof n || typeof t == "string" || typeof t.valueOf() == "string")
|
|
1089
1173
|
super(t.valueOf());
|
|
1090
1174
|
else {
|
|
1091
|
-
const e =
|
|
1175
|
+
const e = n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
|
|
1092
1176
|
if (e == null)
|
|
1093
1177
|
throw new Error(`unable to find data type for ${t.toString()}`);
|
|
1094
1178
|
super(e.valueOf());
|
|
@@ -1098,7 +1182,7 @@ class r extends M {
|
|
|
1098
1182
|
* @returns the TypedArray constructor for the DataType.
|
|
1099
1183
|
*/
|
|
1100
1184
|
get Array() {
|
|
1101
|
-
const t =
|
|
1185
|
+
const t = n.ARRAY_CONSTRUCTORS.get(this.toString());
|
|
1102
1186
|
if (t == null)
|
|
1103
1187
|
throw new Error(`unable to find array constructor for ${this.valueOf()}`);
|
|
1104
1188
|
return t;
|
|
@@ -1125,7 +1209,7 @@ class r extends M {
|
|
|
1125
1209
|
* @example DataType.INT32.isVariable // false
|
|
1126
1210
|
*/
|
|
1127
1211
|
get isVariable() {
|
|
1128
|
-
return this.equals(
|
|
1212
|
+
return this.equals(n.JSON) || this.equals(n.STRING);
|
|
1129
1213
|
}
|
|
1130
1214
|
/**
|
|
1131
1215
|
* @returns true if the DataType is numeric.
|
|
@@ -1133,7 +1217,7 @@ class r extends M {
|
|
|
1133
1217
|
* @example DataType.STRING.isNumeric // false
|
|
1134
1218
|
*/
|
|
1135
1219
|
get isNumeric() {
|
|
1136
|
-
return !this.isVariable && !this.equals(
|
|
1220
|
+
return !this.isVariable && !this.equals(n.UUID);
|
|
1137
1221
|
}
|
|
1138
1222
|
/**
|
|
1139
1223
|
* @returns true if the DataType is an integer.
|
|
@@ -1158,7 +1242,7 @@ class r extends M {
|
|
|
1158
1242
|
* @example DataType.FLOAT32.density // Density.BIT32
|
|
1159
1243
|
*/
|
|
1160
1244
|
get density() {
|
|
1161
|
-
const t =
|
|
1245
|
+
const t = n.DENSITIES.get(this.toString());
|
|
1162
1246
|
if (t == null) throw new Error(`unable to find density for ${this.valueOf()}`);
|
|
1163
1247
|
return t;
|
|
1164
1248
|
}
|
|
@@ -1168,7 +1252,7 @@ class r extends M {
|
|
|
1168
1252
|
* @example DataType.INT32.isUnsigned // false
|
|
1169
1253
|
*/
|
|
1170
1254
|
get isUnsignedInteger() {
|
|
1171
|
-
return this.equals(
|
|
1255
|
+
return this.equals(n.UINT8) || this.equals(n.UINT16) || this.equals(n.UINT32) || this.equals(n.UINT64);
|
|
1172
1256
|
}
|
|
1173
1257
|
/**
|
|
1174
1258
|
* @returns true if the DataType is a signed integer.
|
|
@@ -1176,11 +1260,11 @@ class r extends M {
|
|
|
1176
1260
|
* @example DataType.UINT32.isSigned // false
|
|
1177
1261
|
*/
|
|
1178
1262
|
get isSignedInteger() {
|
|
1179
|
-
return this.equals(
|
|
1263
|
+
return this.equals(n.INT8) || this.equals(n.INT16) || this.equals(n.INT32) || this.equals(n.INT64);
|
|
1180
1264
|
}
|
|
1181
1265
|
/** @returns true if the data type can be cast to the other data type without loss of precision. */
|
|
1182
1266
|
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(
|
|
1267
|
+
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
1268
|
}
|
|
1185
1269
|
/** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
|
|
1186
1270
|
canCastTo(t) {
|
|
@@ -1197,112 +1281,112 @@ class r extends M {
|
|
|
1197
1281
|
}
|
|
1198
1282
|
/** @returns true if the data type uses bigints to store values. */
|
|
1199
1283
|
get usesBigInt() {
|
|
1200
|
-
return
|
|
1284
|
+
return n.BIG_INT_TYPES.some((t) => t.equals(this));
|
|
1201
1285
|
}
|
|
1202
1286
|
/** Represents an Unknown/Invalid DataType. */
|
|
1203
|
-
static UNKNOWN = new
|
|
1287
|
+
static UNKNOWN = new n("unknown");
|
|
1204
1288
|
/** Represents a 64-bit floating point value. */
|
|
1205
|
-
static FLOAT64 = new
|
|
1289
|
+
static FLOAT64 = new n("float64");
|
|
1206
1290
|
/** Represents a 32-bit floating point value. */
|
|
1207
|
-
static FLOAT32 = new
|
|
1291
|
+
static FLOAT32 = new n("float32");
|
|
1208
1292
|
/** Represents a 64-bit signed integer value. */
|
|
1209
|
-
static INT64 = new
|
|
1293
|
+
static INT64 = new n("int64");
|
|
1210
1294
|
/** Represents a 32-bit signed integer value. */
|
|
1211
|
-
static INT32 = new
|
|
1295
|
+
static INT32 = new n("int32");
|
|
1212
1296
|
/** Represents a 16-bit signed integer value. */
|
|
1213
|
-
static INT16 = new
|
|
1297
|
+
static INT16 = new n("int16");
|
|
1214
1298
|
/** Represents a 8-bit signed integer value. */
|
|
1215
|
-
static INT8 = new
|
|
1299
|
+
static INT8 = new n("int8");
|
|
1216
1300
|
/** Represents a 64-bit unsigned integer value. */
|
|
1217
|
-
static UINT64 = new
|
|
1301
|
+
static UINT64 = new n("uint64");
|
|
1218
1302
|
/** Represents a 32-bit unsigned integer value. */
|
|
1219
|
-
static UINT32 = new
|
|
1303
|
+
static UINT32 = new n("uint32");
|
|
1220
1304
|
/** Represents a 16-bit unsigned integer value. */
|
|
1221
|
-
static UINT16 = new
|
|
1305
|
+
static UINT16 = new n("uint16");
|
|
1222
1306
|
/** Represents a 8-bit unsigned integer value. */
|
|
1223
|
-
static UINT8 = new
|
|
1307
|
+
static UINT8 = new n("uint8");
|
|
1224
1308
|
/** Represents a boolean value. Alias for UINT8. */
|
|
1225
1309
|
static BOOLEAN = this.UINT8;
|
|
1226
1310
|
/** Represents a 64-bit unix epoch. */
|
|
1227
|
-
static TIMESTAMP = new
|
|
1311
|
+
static TIMESTAMP = new n("timestamp");
|
|
1228
1312
|
/** Represents a UUID data type */
|
|
1229
|
-
static UUID = new
|
|
1313
|
+
static UUID = new n("uuid");
|
|
1230
1314
|
/** Represents a string data type. Strings have an unknown density, and are separate
|
|
1231
1315
|
* by a newline character. */
|
|
1232
|
-
static STRING = new
|
|
1316
|
+
static STRING = new n("string");
|
|
1233
1317
|
/** Represents a JSON data type. JSON has an unknown density, and is separated by a
|
|
1234
1318
|
* newline character. */
|
|
1235
|
-
static JSON = new
|
|
1319
|
+
static JSON = new n("json");
|
|
1236
1320
|
static ARRAY_CONSTRUCTORS = /* @__PURE__ */ new Map([
|
|
1237
|
-
[
|
|
1238
|
-
[
|
|
1239
|
-
[
|
|
1240
|
-
[
|
|
1241
|
-
[
|
|
1242
|
-
[
|
|
1243
|
-
[
|
|
1244
|
-
[
|
|
1245
|
-
[
|
|
1246
|
-
[
|
|
1247
|
-
[
|
|
1248
|
-
[
|
|
1249
|
-
[
|
|
1250
|
-
[
|
|
1321
|
+
[n.UINT8.toString(), Uint8Array],
|
|
1322
|
+
[n.UINT16.toString(), Uint16Array],
|
|
1323
|
+
[n.UINT32.toString(), Uint32Array],
|
|
1324
|
+
[n.UINT64.toString(), BigUint64Array],
|
|
1325
|
+
[n.FLOAT32.toString(), Float32Array],
|
|
1326
|
+
[n.FLOAT64.toString(), Float64Array],
|
|
1327
|
+
[n.INT8.toString(), Int8Array],
|
|
1328
|
+
[n.INT16.toString(), Int16Array],
|
|
1329
|
+
[n.INT32.toString(), Int32Array],
|
|
1330
|
+
[n.INT64.toString(), BigInt64Array],
|
|
1331
|
+
[n.TIMESTAMP.toString(), BigInt64Array],
|
|
1332
|
+
[n.STRING.toString(), Uint8Array],
|
|
1333
|
+
[n.JSON.toString(), Uint8Array],
|
|
1334
|
+
[n.UUID.toString(), Uint8Array]
|
|
1251
1335
|
]);
|
|
1252
1336
|
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,
|
|
1337
|
+
[Uint8Array.name, n.UINT8],
|
|
1338
|
+
[Uint16Array.name, n.UINT16],
|
|
1339
|
+
[Uint32Array.name, n.UINT32],
|
|
1340
|
+
[BigUint64Array.name, n.UINT64],
|
|
1341
|
+
[Float32Array.name, n.FLOAT32],
|
|
1342
|
+
[Float64Array.name, n.FLOAT64],
|
|
1343
|
+
[Int8Array.name, n.INT8],
|
|
1344
|
+
[Int16Array.name, n.INT16],
|
|
1345
|
+
[Int32Array.name, n.INT32],
|
|
1346
|
+
[BigInt64Array.name, n.INT64]
|
|
1263
1347
|
]);
|
|
1264
1348
|
static DENSITIES = /* @__PURE__ */ new Map([
|
|
1265
|
-
[
|
|
1266
|
-
[
|
|
1267
|
-
[
|
|
1268
|
-
[
|
|
1269
|
-
[
|
|
1270
|
-
[
|
|
1271
|
-
[
|
|
1272
|
-
[
|
|
1273
|
-
[
|
|
1274
|
-
[
|
|
1275
|
-
[
|
|
1276
|
-
[
|
|
1277
|
-
[
|
|
1278
|
-
[
|
|
1349
|
+
[n.UINT8.toString(), d.BIT8],
|
|
1350
|
+
[n.UINT16.toString(), d.BIT16],
|
|
1351
|
+
[n.UINT32.toString(), d.BIT32],
|
|
1352
|
+
[n.UINT64.toString(), d.BIT64],
|
|
1353
|
+
[n.FLOAT32.toString(), d.BIT32],
|
|
1354
|
+
[n.FLOAT64.toString(), d.BIT64],
|
|
1355
|
+
[n.INT8.toString(), d.BIT8],
|
|
1356
|
+
[n.INT16.toString(), d.BIT16],
|
|
1357
|
+
[n.INT32.toString(), d.BIT32],
|
|
1358
|
+
[n.INT64.toString(), d.BIT64],
|
|
1359
|
+
[n.TIMESTAMP.toString(), d.BIT64],
|
|
1360
|
+
[n.STRING.toString(), d.UNKNOWN],
|
|
1361
|
+
[n.JSON.toString(), d.UNKNOWN],
|
|
1362
|
+
[n.UUID.toString(), d.BIT128]
|
|
1279
1363
|
]);
|
|
1280
1364
|
/** All the data types. */
|
|
1281
1365
|
static ALL = [
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1366
|
+
n.UNKNOWN,
|
|
1367
|
+
n.FLOAT64,
|
|
1368
|
+
n.FLOAT32,
|
|
1369
|
+
n.INT64,
|
|
1370
|
+
n.INT32,
|
|
1371
|
+
n.INT16,
|
|
1372
|
+
n.INT8,
|
|
1373
|
+
n.UINT64,
|
|
1374
|
+
n.UINT32,
|
|
1375
|
+
n.UINT16,
|
|
1376
|
+
n.UINT8,
|
|
1377
|
+
n.TIMESTAMP,
|
|
1378
|
+
n.UUID,
|
|
1379
|
+
n.STRING,
|
|
1380
|
+
n.JSON
|
|
1297
1381
|
];
|
|
1298
|
-
static BIG_INT_TYPES = [
|
|
1382
|
+
static BIG_INT_TYPES = [n.INT64, n.UINT64, n.TIMESTAMP];
|
|
1299
1383
|
/** A zod schema for a DataType. */
|
|
1300
1384
|
static z = o.union([
|
|
1301
|
-
o.string().transform((t) => new
|
|
1302
|
-
o.instanceof(
|
|
1385
|
+
o.string().transform((t) => new n(t)),
|
|
1386
|
+
o.instanceof(n)
|
|
1303
1387
|
]);
|
|
1304
1388
|
}
|
|
1305
|
-
class
|
|
1389
|
+
class c extends C {
|
|
1306
1390
|
constructor(t) {
|
|
1307
1391
|
super(t.valueOf());
|
|
1308
1392
|
}
|
|
@@ -1316,41 +1400,59 @@ class h extends M {
|
|
|
1316
1400
|
}
|
|
1317
1401
|
/** @returns a new Size representing the sum of the two Sizes. */
|
|
1318
1402
|
add(t) {
|
|
1319
|
-
return
|
|
1403
|
+
return new c(p(this.valueOf(), t.valueOf()));
|
|
1320
1404
|
}
|
|
1321
1405
|
/** @returns a new Size representing the difference of the two Sizes. */
|
|
1322
1406
|
sub(t) {
|
|
1323
|
-
return
|
|
1407
|
+
return new c(L(this.valueOf(), t.valueOf()));
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Multiplies this Size by a scalar value.
|
|
1411
|
+
*
|
|
1412
|
+
* @param value - The scalar value to multiply by.
|
|
1413
|
+
* @returns A new Size representing this Size multiplied by the value.
|
|
1414
|
+
*/
|
|
1415
|
+
mult(t) {
|
|
1416
|
+
return new c(N(this.valueOf(), t));
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Divides this Size by a scalar value.
|
|
1420
|
+
*
|
|
1421
|
+
* @param value - The scalar value to divide by.
|
|
1422
|
+
* @returns A new Size representing this Size divided by the value.
|
|
1423
|
+
*/
|
|
1424
|
+
div(t) {
|
|
1425
|
+
return new c(S(this.valueOf(), t));
|
|
1324
1426
|
}
|
|
1325
1427
|
/** @returns a new Size representing the truncated value of the Size. */
|
|
1326
1428
|
truncate(t) {
|
|
1327
|
-
return new
|
|
1429
|
+
return new c(Math.trunc(this.valueOf() / t.valueOf()) * t.valueOf());
|
|
1328
1430
|
}
|
|
1329
1431
|
/** @returns a new Size representing the remainder of the Size. */
|
|
1330
1432
|
remainder(t) {
|
|
1331
|
-
return
|
|
1433
|
+
return c.bytes(this.valueOf() % t.valueOf());
|
|
1332
1434
|
}
|
|
1333
1435
|
/** @returns the number of gigabytes in the Size. */
|
|
1334
1436
|
get gigabytes() {
|
|
1335
|
-
return this.valueOf() /
|
|
1437
|
+
return this.valueOf() / c.GIGABYTE.valueOf();
|
|
1336
1438
|
}
|
|
1337
1439
|
/** @returns the number of megabytes in the Size. */
|
|
1338
1440
|
get megabytes() {
|
|
1339
|
-
return this.valueOf() /
|
|
1441
|
+
return this.valueOf() / c.MEGABYTE.valueOf();
|
|
1340
1442
|
}
|
|
1341
1443
|
/** @returns the number of kilobytes in the Size. */
|
|
1342
1444
|
get kilobytes() {
|
|
1343
|
-
return this.valueOf() /
|
|
1445
|
+
return this.valueOf() / c.KILOBYTE.valueOf();
|
|
1344
1446
|
}
|
|
1345
1447
|
/** @returns the number of terabytes in the Size. */
|
|
1346
1448
|
get terabytes() {
|
|
1347
|
-
return this.valueOf() /
|
|
1449
|
+
return this.valueOf() / c.TERABYTE.valueOf();
|
|
1348
1450
|
}
|
|
1349
1451
|
/** @returns a nicely formatted string representation of the Size. */
|
|
1350
1452
|
toString() {
|
|
1351
|
-
const t = this.truncate(
|
|
1352
|
-
let
|
|
1353
|
-
return
|
|
1453
|
+
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);
|
|
1454
|
+
let b = "";
|
|
1455
|
+
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
1456
|
}
|
|
1355
1457
|
/**
|
|
1356
1458
|
* Creates a Size from the given number of bytes.
|
|
@@ -1359,10 +1461,10 @@ class h extends M {
|
|
|
1359
1461
|
* @returns A Size representing the given number of bytes.
|
|
1360
1462
|
*/
|
|
1361
1463
|
static bytes(t = 1) {
|
|
1362
|
-
return new
|
|
1464
|
+
return new c(t);
|
|
1363
1465
|
}
|
|
1364
1466
|
/** A single byte */
|
|
1365
|
-
static BYTE = new
|
|
1467
|
+
static BYTE = new c(1);
|
|
1366
1468
|
/**
|
|
1367
1469
|
* Creates a Size from the given number if kilobytes.
|
|
1368
1470
|
*
|
|
@@ -1370,10 +1472,10 @@ class h extends M {
|
|
|
1370
1472
|
* @returns A Size representing the given number of kilobytes.
|
|
1371
1473
|
*/
|
|
1372
1474
|
static kilobytes(t = 1) {
|
|
1373
|
-
return
|
|
1475
|
+
return c.bytes(t.valueOf() * 1e3);
|
|
1374
1476
|
}
|
|
1375
1477
|
/** A kilobyte */
|
|
1376
|
-
static KILOBYTE =
|
|
1478
|
+
static KILOBYTE = c.kilobytes(1);
|
|
1377
1479
|
/**
|
|
1378
1480
|
* Creates a Size from the given number of megabytes.
|
|
1379
1481
|
*
|
|
@@ -1381,10 +1483,10 @@ class h extends M {
|
|
|
1381
1483
|
* @returns A Size representing the given number of megabytes.
|
|
1382
1484
|
*/
|
|
1383
1485
|
static megabytes(t = 1) {
|
|
1384
|
-
return
|
|
1486
|
+
return c.kilobytes(t.valueOf() * 1e3);
|
|
1385
1487
|
}
|
|
1386
1488
|
/** A megabyte */
|
|
1387
|
-
static MEGABYTE =
|
|
1489
|
+
static MEGABYTE = c.megabytes(1);
|
|
1388
1490
|
/**
|
|
1389
1491
|
* Creates a Size from the given number of gigabytes.
|
|
1390
1492
|
*
|
|
@@ -1392,10 +1494,10 @@ class h extends M {
|
|
|
1392
1494
|
* @returns A Size representing the given number of gigabytes.
|
|
1393
1495
|
*/
|
|
1394
1496
|
static gigabytes(t = 1) {
|
|
1395
|
-
return
|
|
1497
|
+
return c.megabytes(t.valueOf() * 1e3);
|
|
1396
1498
|
}
|
|
1397
1499
|
/** A gigabyte */
|
|
1398
|
-
static GIGABYTE =
|
|
1500
|
+
static GIGABYTE = c.gigabytes(1);
|
|
1399
1501
|
/**
|
|
1400
1502
|
* Creates a Size from the given number of terabytes.
|
|
1401
1503
|
*
|
|
@@ -1403,23 +1505,23 @@ class h extends M {
|
|
|
1403
1505
|
* @returns A Size representing the given number of terabytes.
|
|
1404
1506
|
*/
|
|
1405
1507
|
static terabytes(t) {
|
|
1406
|
-
return
|
|
1508
|
+
return c.gigabytes(t.valueOf() * 1e3);
|
|
1407
1509
|
}
|
|
1408
1510
|
/** A terabyte. */
|
|
1409
|
-
static TERABYTE =
|
|
1511
|
+
static TERABYTE = c.terabytes(1);
|
|
1410
1512
|
/** The zero value for Size */
|
|
1411
|
-
static ZERO = new
|
|
1513
|
+
static ZERO = new c(0);
|
|
1412
1514
|
/** A zod schema for a Size. */
|
|
1413
1515
|
static z = o.union([
|
|
1414
|
-
o.number().transform((t) => new
|
|
1415
|
-
o.instanceof(
|
|
1516
|
+
o.number().transform((t) => new c(t)),
|
|
1517
|
+
o.instanceof(c)
|
|
1416
1518
|
]);
|
|
1417
1519
|
/** @returns true if the Size is zero. */
|
|
1418
1520
|
get isZero() {
|
|
1419
1521
|
return this.valueOf() === 0;
|
|
1420
1522
|
}
|
|
1421
1523
|
}
|
|
1422
|
-
const
|
|
1524
|
+
const Jt = o.union([
|
|
1423
1525
|
o.instanceof(Uint8Array),
|
|
1424
1526
|
o.instanceof(Uint16Array),
|
|
1425
1527
|
o.instanceof(Uint32Array),
|
|
@@ -1430,64 +1532,64 @@ const Yt = o.union([
|
|
|
1430
1532
|
o.instanceof(Int16Array),
|
|
1431
1533
|
o.instanceof(Int32Array),
|
|
1432
1534
|
o.instanceof(BigInt64Array)
|
|
1433
|
-
]),
|
|
1434
|
-
const t = typeof
|
|
1435
|
-
return t === "string" || t === "number" || t === "boolean" || t === "bigint" ||
|
|
1436
|
-
},
|
|
1437
|
-
function
|
|
1438
|
-
return typeof
|
|
1535
|
+
]), z = (a) => {
|
|
1536
|
+
const t = typeof a;
|
|
1537
|
+
return t === "string" || t === "number" || t === "boolean" || t === "bigint" || a instanceof r || a instanceof i || a instanceof Date;
|
|
1538
|
+
}, 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;
|
|
1539
|
+
function wt(a) {
|
|
1540
|
+
return typeof a == "string" && Ot.test(a);
|
|
1439
1541
|
}
|
|
1440
1542
|
const O = [];
|
|
1441
|
-
for (let
|
|
1442
|
-
O.push((
|
|
1443
|
-
function
|
|
1444
|
-
return (O[
|
|
1543
|
+
for (let a = 0; a < 256; ++a)
|
|
1544
|
+
O.push((a + 256).toString(16).slice(1));
|
|
1545
|
+
function _(a, t = 0) {
|
|
1546
|
+
return (O[a[t + 0]] + O[a[t + 1]] + O[a[t + 2]] + O[a[t + 3]] + "-" + O[a[t + 4]] + O[a[t + 5]] + "-" + O[a[t + 6]] + O[a[t + 7]] + "-" + O[a[t + 8]] + O[a[t + 9]] + "-" + O[a[t + 10]] + O[a[t + 11]] + O[a[t + 12]] + O[a[t + 13]] + O[a[t + 14]] + O[a[t + 15]]).toLowerCase();
|
|
1445
1547
|
}
|
|
1446
|
-
function
|
|
1447
|
-
const e =
|
|
1448
|
-
if (!
|
|
1548
|
+
function bt(a, t = 0) {
|
|
1549
|
+
const e = _(a, t);
|
|
1550
|
+
if (!wt(e))
|
|
1449
1551
|
throw TypeError("Stringified UUID is invalid");
|
|
1450
1552
|
return e;
|
|
1451
1553
|
}
|
|
1452
|
-
let
|
|
1453
|
-
const
|
|
1454
|
-
function
|
|
1455
|
-
if (!
|
|
1554
|
+
let q;
|
|
1555
|
+
const It = new Uint8Array(16);
|
|
1556
|
+
function yt() {
|
|
1557
|
+
if (!q) {
|
|
1456
1558
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1457
1559
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1458
|
-
|
|
1560
|
+
q = crypto.getRandomValues.bind(crypto);
|
|
1459
1561
|
}
|
|
1460
|
-
return
|
|
1562
|
+
return q(It);
|
|
1461
1563
|
}
|
|
1462
|
-
const
|
|
1463
|
-
function
|
|
1464
|
-
if (
|
|
1465
|
-
return
|
|
1466
|
-
|
|
1467
|
-
const s =
|
|
1564
|
+
const mt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), G = { randomUUID: mt };
|
|
1565
|
+
function Nt(a, t, e) {
|
|
1566
|
+
if (G.randomUUID && !a)
|
|
1567
|
+
return G.randomUUID();
|
|
1568
|
+
a = a || {};
|
|
1569
|
+
const s = a.random ?? a.rng?.() ?? yt();
|
|
1468
1570
|
if (s.length < 16)
|
|
1469
1571
|
throw new Error("Random bytes length must be >= 16");
|
|
1470
|
-
return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128,
|
|
1572
|
+
return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, _(s);
|
|
1471
1573
|
}
|
|
1472
|
-
const
|
|
1574
|
+
const vt = () => Nt(), Z = (a, t) => bt(a, t), Ut = gt, jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1473
1575
|
__proto__: null,
|
|
1474
|
-
ZERO:
|
|
1475
|
-
create:
|
|
1476
|
-
parse:
|
|
1477
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1478
|
-
[Symbol.iterator]: () =>
|
|
1576
|
+
ZERO: Ut,
|
|
1577
|
+
create: vt,
|
|
1578
|
+
parse: Z
|
|
1579
|
+
}, Symbol.toStringTag, { value: "Module" })), B = -1, F = {
|
|
1580
|
+
[Symbol.iterator]: () => F,
|
|
1479
1581
|
next: () => ({ done: !0, value: void 0 })
|
|
1480
|
-
},
|
|
1481
|
-
(
|
|
1482
|
-
atob(
|
|
1582
|
+
}, At = o.string().transform(
|
|
1583
|
+
(a) => new Uint8Array(
|
|
1584
|
+
atob(a).split("").map((t) => t.charCodeAt(0))
|
|
1483
1585
|
).buffer
|
|
1484
|
-
),
|
|
1485
|
-
if (
|
|
1586
|
+
), Mt = o.union([o.null(), o.undefined()]).transform(() => new Uint8Array().buffer), Y = 10, tt = (a, t) => {
|
|
1587
|
+
if (a === "number" && !t.isNumeric)
|
|
1486
1588
|
throw new Error(`cannot convert series of type ${t.toString()} to number`);
|
|
1487
|
-
if (
|
|
1589
|
+
if (a === "bigint" && !t.usesBigInt)
|
|
1488
1590
|
throw new Error(`cannot convert series of type ${t.toString()} to bigint`);
|
|
1489
|
-
},
|
|
1490
|
-
class
|
|
1591
|
+
}, et = "sy_x_telem_series";
|
|
1592
|
+
class v {
|
|
1491
1593
|
/**
|
|
1492
1594
|
* A unique identifier for the series. If specified by the user, it is their
|
|
1493
1595
|
* responsibility to ensure that it is unique. If not specified, a new ID will be
|
|
@@ -1498,7 +1600,7 @@ class I {
|
|
|
1498
1600
|
* A discriminator used for identifying instances of the series class even
|
|
1499
1601
|
* when bundlers mangle the class name.
|
|
1500
1602
|
*/
|
|
1501
|
-
discriminator =
|
|
1603
|
+
discriminator = et;
|
|
1502
1604
|
/** The data type of the series. */
|
|
1503
1605
|
dataType;
|
|
1504
1606
|
/**
|
|
@@ -1520,12 +1622,18 @@ class I {
|
|
|
1520
1622
|
* group. Useful for defining the position of the series within a channel's data.
|
|
1521
1623
|
*/
|
|
1522
1624
|
alignment = 0n;
|
|
1625
|
+
/**
|
|
1626
|
+
* Alignment multiple defines the number of alignment steps taken per sample. This is
|
|
1627
|
+
* useful for when the samples in a series represent a partial view of the raw data
|
|
1628
|
+
* i.e. decimation or averaging.
|
|
1629
|
+
*/
|
|
1630
|
+
alignmentMultiple = 1n;
|
|
1523
1631
|
/** A cached minimum value. */
|
|
1524
1632
|
cachedMin;
|
|
1525
1633
|
/** A cached maximum value. */
|
|
1526
1634
|
cachedMax;
|
|
1527
1635
|
/** The write position of the buffer. */
|
|
1528
|
-
writePos =
|
|
1636
|
+
writePos = B;
|
|
1529
1637
|
/** Tracks the number of entities currently using this array. */
|
|
1530
1638
|
_refCount = 0;
|
|
1531
1639
|
/** Caches the length of the array for variable length data types. */
|
|
@@ -1538,21 +1646,21 @@ class I {
|
|
|
1538
1646
|
*/
|
|
1539
1647
|
static crudeZ = o.object({
|
|
1540
1648
|
timeRange: w.z.optional(),
|
|
1541
|
-
dataType:
|
|
1649
|
+
dataType: n.z,
|
|
1542
1650
|
alignment: o.coerce.bigint().optional(),
|
|
1543
1651
|
data: o.union([
|
|
1544
|
-
|
|
1545
|
-
|
|
1652
|
+
At,
|
|
1653
|
+
Mt,
|
|
1546
1654
|
o.instanceof(ArrayBuffer),
|
|
1547
1655
|
o.instanceof(Uint8Array)
|
|
1548
1656
|
]),
|
|
1549
|
-
glBufferUsage:
|
|
1657
|
+
glBufferUsage: ht.optional().default("static").optional()
|
|
1550
1658
|
});
|
|
1551
1659
|
/**
|
|
1552
1660
|
* A zod schema that validates and constructs a series from it's crude
|
|
1553
1661
|
* representation.
|
|
1554
1662
|
*/
|
|
1555
|
-
static z =
|
|
1663
|
+
static z = v.crudeZ.transform((t) => new v(t));
|
|
1556
1664
|
/**
|
|
1557
1665
|
* The Series constructor accepts either a SeriesArgs object or a CrudeSeries value.
|
|
1558
1666
|
*
|
|
@@ -1627,73 +1735,74 @@ class I {
|
|
|
1627
1735
|
* @throws Error if data type cannot be inferred from input
|
|
1628
1736
|
*/
|
|
1629
1737
|
constructor(t) {
|
|
1630
|
-
|
|
1738
|
+
Et(t) && (t = { data: t }), t.data ??= [];
|
|
1631
1739
|
const {
|
|
1632
1740
|
dataType: e,
|
|
1633
1741
|
timeRange: s,
|
|
1634
1742
|
sampleOffset: u = 0,
|
|
1635
|
-
glBufferUsage:
|
|
1636
|
-
alignment:
|
|
1637
|
-
|
|
1743
|
+
glBufferUsage: l = "static",
|
|
1744
|
+
alignment: h = 0n,
|
|
1745
|
+
alignmentMultiple: U = 1n,
|
|
1746
|
+
key: y = X(),
|
|
1638
1747
|
data: g
|
|
1639
1748
|
} = t;
|
|
1640
|
-
if (
|
|
1641
|
-
const
|
|
1642
|
-
this.key =
|
|
1749
|
+
if (st(g)) {
|
|
1750
|
+
const f = g;
|
|
1751
|
+
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
1752
|
return;
|
|
1644
1753
|
}
|
|
1645
|
-
const
|
|
1646
|
-
if (e != null) this.dataType = new
|
|
1754
|
+
const m = z(g), b = Array.isArray(g);
|
|
1755
|
+
if (e != null) this.dataType = new n(e);
|
|
1647
1756
|
else {
|
|
1648
1757
|
if (g instanceof ArrayBuffer)
|
|
1649
1758
|
throw new Error(
|
|
1650
1759
|
"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
|
|
1651
1760
|
);
|
|
1652
|
-
if (
|
|
1653
|
-
let
|
|
1654
|
-
if (!
|
|
1761
|
+
if (b || m) {
|
|
1762
|
+
let f = g;
|
|
1763
|
+
if (!m) {
|
|
1655
1764
|
if (g.length === 0)
|
|
1656
1765
|
throw new Error(
|
|
1657
1766
|
"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
|
|
1658
1767
|
);
|
|
1659
|
-
|
|
1768
|
+
f = g[0];
|
|
1660
1769
|
}
|
|
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
|
|
1770
|
+
if (typeof f == "string") this.dataType = n.STRING;
|
|
1771
|
+
else if (typeof f == "number") this.dataType = n.FLOAT64;
|
|
1772
|
+
else if (typeof f == "bigint") this.dataType = n.INT64;
|
|
1773
|
+
else if (typeof f == "boolean") this.dataType = n.BOOLEAN;
|
|
1774
|
+
else if (f instanceof r || f instanceof Date || f instanceof r)
|
|
1775
|
+
this.dataType = n.TIMESTAMP;
|
|
1776
|
+
else if (typeof f == "object") this.dataType = n.JSON;
|
|
1668
1777
|
else
|
|
1669
1778
|
throw new Error(
|
|
1670
|
-
`cannot infer data type of ${typeof
|
|
1779
|
+
`cannot infer data type of ${typeof f} when constructing a Series from a JS array`
|
|
1671
1780
|
);
|
|
1672
|
-
} else this.dataType = new
|
|
1781
|
+
} else this.dataType = new n(g);
|
|
1673
1782
|
}
|
|
1674
|
-
if (!
|
|
1675
|
-
else if (
|
|
1783
|
+
if (!b && !m) this._data = g;
|
|
1784
|
+
else if (b && g.length === 0)
|
|
1676
1785
|
this._data = new this.dataType.Array([]).buffer;
|
|
1677
1786
|
else {
|
|
1678
|
-
let
|
|
1679
|
-
const
|
|
1680
|
-
(
|
|
1787
|
+
let f = m ? [g] : g;
|
|
1788
|
+
const A = f[0];
|
|
1789
|
+
(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
1790
|
`)}
|
|
1682
|
-
`).buffer) : this.dataType.equals(
|
|
1683
|
-
`${
|
|
1791
|
+
`).buffer) : this.dataType.equals(n.JSON) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(
|
|
1792
|
+
`${f.map((M) => $.encodeString(M)).join(`
|
|
1684
1793
|
`)}
|
|
1685
1794
|
`
|
|
1686
|
-
).buffer) : this.dataType.usesBigInt && typeof
|
|
1687
|
-
|
|
1688
|
-
).buffer : !this.dataType.usesBigInt && typeof
|
|
1689
|
-
|
|
1690
|
-
).buffer : this._data = new this.dataType.Array(
|
|
1795
|
+
).buffer) : this.dataType.usesBigInt && typeof A == "number" ? this._data = new this.dataType.Array(
|
|
1796
|
+
f.map((M) => BigInt(Math.round(M)))
|
|
1797
|
+
).buffer : !this.dataType.usesBigInt && typeof A == "bigint" ? this._data = new this.dataType.Array(
|
|
1798
|
+
f.map(Number)
|
|
1799
|
+
).buffer : this._data = new this.dataType.Array(f).buffer;
|
|
1691
1800
|
}
|
|
1692
|
-
this.key = y, this.alignment =
|
|
1801
|
+
this.key = y, this.alignment = h, this.alignmentMultiple = U, this.sampleOffset = u ?? 0, this.timeRange = s ?? w.ZERO, this.gl = {
|
|
1693
1802
|
control: null,
|
|
1694
1803
|
buffer: null,
|
|
1695
1804
|
prevBuffer: 0,
|
|
1696
|
-
bufferUsage:
|
|
1805
|
+
bufferUsage: l
|
|
1697
1806
|
};
|
|
1698
1807
|
}
|
|
1699
1808
|
/**
|
|
@@ -1706,8 +1815,8 @@ class I {
|
|
|
1706
1815
|
static alloc({ capacity: t, dataType: e, ...s }) {
|
|
1707
1816
|
if (t === 0)
|
|
1708
1817
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
1709
|
-
const u = new new
|
|
1710
|
-
return
|
|
1818
|
+
const u = new new n(e).Array(t), l = new v({ data: u.buffer, dataType: e, ...s });
|
|
1819
|
+
return l.writePos = 0, l;
|
|
1711
1820
|
}
|
|
1712
1821
|
/**
|
|
1713
1822
|
* @returns the number of references to this series i.e. the number of times this
|
|
@@ -1749,12 +1858,12 @@ class I {
|
|
|
1749
1858
|
return this.dataType.isVariable ? this.writeVariable(t) : this.writeFixed(t);
|
|
1750
1859
|
}
|
|
1751
1860
|
writeVariable(t) {
|
|
1752
|
-
if (this.writePos ===
|
|
1861
|
+
if (this.writePos === B) return 0;
|
|
1753
1862
|
const e = this.byteCapacity.valueOf() - this.writePos, s = t.subBytes(0, e);
|
|
1754
1863
|
return this.writeToUnderlyingData(s), this.writePos += s.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += s.length, this.calculateCachedLength()), s.length;
|
|
1755
1864
|
}
|
|
1756
1865
|
writeFixed(t) {
|
|
1757
|
-
if (this.writePos ===
|
|
1866
|
+
if (this.writePos === B) return 0;
|
|
1758
1867
|
const e = this.capacity - this.writePos, s = t.sub(0, e);
|
|
1759
1868
|
return this.writeToUnderlyingData(s), this.cachedLength = void 0, this.maybeRecomputeMinMax(s), this.writePos += s.length, s.length;
|
|
1760
1869
|
}
|
|
@@ -1777,7 +1886,7 @@ class I {
|
|
|
1777
1886
|
* @returns A typed array containing the series data.
|
|
1778
1887
|
*/
|
|
1779
1888
|
get data() {
|
|
1780
|
-
return this.writePos ===
|
|
1889
|
+
return this.writePos === B ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
|
|
1781
1890
|
}
|
|
1782
1891
|
/**
|
|
1783
1892
|
* Returns an array of the values in the series as strings.
|
|
@@ -1796,16 +1905,16 @@ class I {
|
|
|
1796
1905
|
* @returns An array of values parsed from the JSON series.
|
|
1797
1906
|
*/
|
|
1798
1907
|
parseJSON(t) {
|
|
1799
|
-
if (!this.dataType.equals(
|
|
1908
|
+
if (!this.dataType.equals(n.JSON))
|
|
1800
1909
|
throw new Error("cannot parse non-JSON series as JSON");
|
|
1801
|
-
return this.toStrings().map((e) => t.parse(
|
|
1910
|
+
return this.toStrings().map((e) => t.parse($.decodeString(e)));
|
|
1802
1911
|
}
|
|
1803
1912
|
/**
|
|
1804
1913
|
* Returns the capacity of the series in bytes.
|
|
1805
1914
|
* @returns The size of the underlying buffer in bytes.
|
|
1806
1915
|
*/
|
|
1807
1916
|
get byteCapacity() {
|
|
1808
|
-
return new
|
|
1917
|
+
return new c(this.underlyingData.byteLength);
|
|
1809
1918
|
}
|
|
1810
1919
|
/**
|
|
1811
1920
|
* Returns the capacity of the series in samples.
|
|
@@ -1821,7 +1930,7 @@ class I {
|
|
|
1821
1930
|
* @returns The size of the data in bytes.
|
|
1822
1931
|
*/
|
|
1823
1932
|
get byteLength() {
|
|
1824
|
-
return this.writePos ===
|
|
1933
|
+
return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new c(this.writePos) : this.dataType.density.size(this.writePos);
|
|
1825
1934
|
}
|
|
1826
1935
|
/**
|
|
1827
1936
|
* Returns the number of samples in this array.
|
|
@@ -1829,7 +1938,7 @@ class I {
|
|
|
1829
1938
|
* @returns The number of samples in the series.
|
|
1830
1939
|
*/
|
|
1831
1940
|
get length() {
|
|
1832
|
-
return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos ===
|
|
1941
|
+
return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === B ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
|
|
1833
1942
|
}
|
|
1834
1943
|
calculateCachedLength() {
|
|
1835
1944
|
if (!this.dataType.isVariable)
|
|
@@ -1837,7 +1946,7 @@ class I {
|
|
|
1837
1946
|
let t = 0;
|
|
1838
1947
|
const e = [0];
|
|
1839
1948
|
return this.data.forEach((s, u) => {
|
|
1840
|
-
s ===
|
|
1949
|
+
s === Y && (t++, e.push(u + 1));
|
|
1841
1950
|
}), this._cachedIndexes = e, this.cachedLength = t, t;
|
|
1842
1951
|
}
|
|
1843
1952
|
/**
|
|
@@ -1853,8 +1962,8 @@ class I {
|
|
|
1853
1962
|
if (this.dataType.equals(t)) return this;
|
|
1854
1963
|
const s = new t.Array(this.length);
|
|
1855
1964
|
for (let u = 0; u < this.length; u++)
|
|
1856
|
-
s[u] =
|
|
1857
|
-
return new
|
|
1965
|
+
s[u] = dt(this.dataType, t, this.data[u], e);
|
|
1966
|
+
return new v({
|
|
1858
1967
|
data: s.buffer,
|
|
1859
1968
|
dataType: t,
|
|
1860
1969
|
timeRange: this.timeRange,
|
|
@@ -1865,7 +1974,7 @@ class I {
|
|
|
1865
1974
|
}
|
|
1866
1975
|
calcRawMax() {
|
|
1867
1976
|
if (this.length === 0) return -1 / 0;
|
|
1868
|
-
if (this.dataType.equals(
|
|
1977
|
+
if (this.dataType.equals(n.TIMESTAMP))
|
|
1869
1978
|
this.cachedMax = this.data[this.data.length - 1];
|
|
1870
1979
|
else if (this.dataType.usesBigInt) {
|
|
1871
1980
|
const t = this.data;
|
|
@@ -1883,11 +1992,11 @@ class I {
|
|
|
1883
1992
|
calcMax() {
|
|
1884
1993
|
if (this.dataType.isVariable)
|
|
1885
1994
|
throw new Error("cannot calculate maximum on a variable length data type");
|
|
1886
|
-
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(),
|
|
1995
|
+
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), T(this.cachedMax, this.sampleOffset));
|
|
1887
1996
|
}
|
|
1888
1997
|
calcRawMin() {
|
|
1889
1998
|
if (this.length === 0) return 1 / 0;
|
|
1890
|
-
if (this.dataType.equals(
|
|
1999
|
+
if (this.dataType.equals(n.TIMESTAMP)) this.cachedMin = this.data[0];
|
|
1891
2000
|
else if (this.dataType.usesBigInt) {
|
|
1892
2001
|
const t = this.data;
|
|
1893
2002
|
this.cachedMin = t.reduce((e, s) => e < s ? e : s);
|
|
@@ -1904,11 +2013,11 @@ class I {
|
|
|
1904
2013
|
calcMin() {
|
|
1905
2014
|
if (this.dataType.isVariable)
|
|
1906
2015
|
throw new Error("cannot calculate minimum on a variable length data type");
|
|
1907
|
-
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(),
|
|
2016
|
+
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), T(this.cachedMin, this.sampleOffset));
|
|
1908
2017
|
}
|
|
1909
2018
|
/** @returns the bounds of the series. */
|
|
1910
2019
|
get bounds() {
|
|
1911
|
-
return
|
|
2020
|
+
return x(Number(this.min), Number(this.max), { makeValid: !1 });
|
|
1912
2021
|
}
|
|
1913
2022
|
maybeRecomputeMinMax(t) {
|
|
1914
2023
|
if (this.cachedMin != null) {
|
|
@@ -1921,7 +2030,7 @@ class I {
|
|
|
1921
2030
|
}
|
|
1922
2031
|
}
|
|
1923
2032
|
atAlignment(t, e) {
|
|
1924
|
-
const s = Number(t - this.alignment);
|
|
2033
|
+
const s = Number((t - this.alignment) / this.alignmentMultiple);
|
|
1925
2034
|
if (s < 0 || s >= this.length) {
|
|
1926
2035
|
if (e === !0) throw new Error(`[series] - no value at index ${s}`);
|
|
1927
2036
|
return;
|
|
@@ -1930,18 +2039,18 @@ class I {
|
|
|
1930
2039
|
}
|
|
1931
2040
|
at(t, e = !1) {
|
|
1932
2041
|
if (this.dataType.isVariable) return this.atVariable(t, e ?? !1);
|
|
1933
|
-
if (this.dataType.equals(
|
|
2042
|
+
if (this.dataType.equals(n.UUID)) return this.atUUID(t, e);
|
|
1934
2043
|
t < 0 && (t = this.length + t);
|
|
1935
2044
|
const s = this.data[t];
|
|
1936
2045
|
if (s == null) {
|
|
1937
2046
|
if (e === !0) throw new Error(`[series] - no value at index ${t}`);
|
|
1938
2047
|
return;
|
|
1939
2048
|
}
|
|
1940
|
-
return
|
|
2049
|
+
return T(s, this.sampleOffset);
|
|
1941
2050
|
}
|
|
1942
2051
|
atUUID(t, e) {
|
|
1943
2052
|
t < 0 && (t = this.length + t);
|
|
1944
|
-
const s =
|
|
2053
|
+
const s = Z(
|
|
1945
2054
|
new Uint8Array(this.buffer, t * this.dataType.density.valueOf())
|
|
1946
2055
|
);
|
|
1947
2056
|
if (s == null) {
|
|
@@ -1956,21 +2065,21 @@ class I {
|
|
|
1956
2065
|
s = this._cachedIndexes[t], u = this._cachedIndexes[t + 1] - 1;
|
|
1957
2066
|
else {
|
|
1958
2067
|
t < 0 && (t = this.length + t);
|
|
1959
|
-
for (let
|
|
1960
|
-
if (this.data[
|
|
2068
|
+
for (let h = 0; h < this.data.length; h++)
|
|
2069
|
+
if (this.data[h] === Y) {
|
|
1961
2070
|
if (t === 0) {
|
|
1962
|
-
u =
|
|
2071
|
+
u = h;
|
|
1963
2072
|
break;
|
|
1964
2073
|
}
|
|
1965
|
-
s =
|
|
2074
|
+
s = h + 1, t--;
|
|
1966
2075
|
}
|
|
1967
2076
|
if (u === 0 && (u = this.data.length), s >= u || t > 0) {
|
|
1968
2077
|
if (e) throw new Error(`[series] - no value at index ${t}`);
|
|
1969
2078
|
return;
|
|
1970
2079
|
}
|
|
1971
2080
|
}
|
|
1972
|
-
const
|
|
1973
|
-
return this.dataType.equals(
|
|
2081
|
+
const l = this.data.slice(s, u);
|
|
2082
|
+
return this.dataType.equals(n.STRING) ? new TextDecoder().decode(l) : nt(JSON.parse(new TextDecoder().decode(l)));
|
|
1974
2083
|
}
|
|
1975
2084
|
/**
|
|
1976
2085
|
* @returns the index of the first sample that is greater than or equal to the given value.
|
|
@@ -1979,11 +2088,11 @@ class I {
|
|
|
1979
2088
|
*/
|
|
1980
2089
|
binarySearch(t) {
|
|
1981
2090
|
let e = 0, s = this.length - 1;
|
|
1982
|
-
const u =
|
|
2091
|
+
const u = rt(t);
|
|
1983
2092
|
for (; e <= s; ) {
|
|
1984
|
-
const
|
|
1985
|
-
if (
|
|
1986
|
-
|
|
2093
|
+
const l = Math.floor((e + s) / 2), h = u(this.at(l, !0), t);
|
|
2094
|
+
if (h === 0) return l;
|
|
2095
|
+
h < 0 ? e = l + 1 : s = l - 1;
|
|
1987
2096
|
}
|
|
1988
2097
|
return e;
|
|
1989
2098
|
}
|
|
@@ -1995,23 +2104,23 @@ class I {
|
|
|
1995
2104
|
* be the same buffer previously passed to {@method acquire} or {@method updateGLBuffer}.
|
|
1996
2105
|
*/
|
|
1997
2106
|
updateGLBuffer(t) {
|
|
1998
|
-
if (this.gl.control = t, !this.dataType.equals(
|
|
2107
|
+
if (this.gl.control = t, !this.dataType.equals(n.FLOAT32) && !this.dataType.equals(n.UINT8))
|
|
1999
2108
|
throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
|
|
2000
2109
|
const { buffer: e, bufferUsage: s, prevBuffer: u } = this.gl;
|
|
2001
2110
|
if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== u)
|
|
2002
|
-
if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !==
|
|
2111
|
+
if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !== B) {
|
|
2003
2112
|
u === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
|
|
2004
|
-
const
|
|
2005
|
-
t.bufferSubData(t.ARRAY_BUFFER,
|
|
2113
|
+
const l = this.dataType.density.size(u).valueOf(), h = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
|
|
2114
|
+
t.bufferSubData(t.ARRAY_BUFFER, l, h.buffer), this.gl.prevBuffer = this.writePos;
|
|
2006
2115
|
} else
|
|
2007
2116
|
t.bufferData(
|
|
2008
2117
|
t.ARRAY_BUFFER,
|
|
2009
2118
|
this.buffer,
|
|
2010
2119
|
s === "static" ? t.STATIC_DRAW : t.DYNAMIC_DRAW
|
|
2011
|
-
), this.gl.prevBuffer =
|
|
2120
|
+
), this.gl.prevBuffer = B;
|
|
2012
2121
|
}
|
|
2013
2122
|
as(t) {
|
|
2014
|
-
return
|
|
2123
|
+
return tt(t, this.dataType), this;
|
|
2015
2124
|
}
|
|
2016
2125
|
/** @returns a digest containing information about the series. */
|
|
2017
2126
|
get digest() {
|
|
@@ -2020,8 +2129,8 @@ class I {
|
|
|
2020
2129
|
dataType: this.dataType.toString(),
|
|
2021
2130
|
sampleOffset: this.sampleOffset,
|
|
2022
2131
|
alignment: {
|
|
2023
|
-
lower:
|
|
2024
|
-
upper:
|
|
2132
|
+
lower: j(this.alignmentBounds.lower),
|
|
2133
|
+
upper: j(this.alignmentBounds.upper)
|
|
2025
2134
|
},
|
|
2026
2135
|
timeRange: this.timeRange.toString(),
|
|
2027
2136
|
length: this.length,
|
|
@@ -2038,7 +2147,10 @@ class I {
|
|
|
2038
2147
|
* is exclusive.
|
|
2039
2148
|
*/
|
|
2040
2149
|
get alignmentBounds() {
|
|
2041
|
-
return
|
|
2150
|
+
return x(
|
|
2151
|
+
this.alignment,
|
|
2152
|
+
this.alignment + BigInt(this.length) * this.alignmentMultiple
|
|
2153
|
+
);
|
|
2042
2154
|
}
|
|
2043
2155
|
maybeGarbageCollectGLBuffer(t) {
|
|
2044
2156
|
this.gl.buffer != null && (t.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
|
|
@@ -2055,10 +2167,10 @@ class I {
|
|
|
2055
2167
|
}
|
|
2056
2168
|
[Symbol.iterator]() {
|
|
2057
2169
|
if (this.dataType.isVariable) {
|
|
2058
|
-
const t = new
|
|
2059
|
-
return this.dataType.equals(
|
|
2170
|
+
const t = new Bt(this);
|
|
2171
|
+
return this.dataType.equals(n.JSON) ? new V(t) : t;
|
|
2060
2172
|
}
|
|
2061
|
-
return this.dataType.equals(
|
|
2173
|
+
return this.dataType.equals(n.UUID) ? new Ct(this) : new xt(this);
|
|
2062
2174
|
}
|
|
2063
2175
|
/**
|
|
2064
2176
|
* Returns a slice of the series from start to end.
|
|
@@ -2085,7 +2197,7 @@ class I {
|
|
|
2085
2197
|
* @returns An iterator over the specified range.
|
|
2086
2198
|
*/
|
|
2087
2199
|
subIterator(t, e) {
|
|
2088
|
-
return new
|
|
2200
|
+
return new J(this, t, e ?? this.length);
|
|
2089
2201
|
}
|
|
2090
2202
|
/**
|
|
2091
2203
|
* Returns an iterator over a portion of the series based on alignment.
|
|
@@ -2094,16 +2206,17 @@ class I {
|
|
|
2094
2206
|
* @returns An iterator over the specified alignment range.
|
|
2095
2207
|
*/
|
|
2096
2208
|
subAlignmentIterator(t, e) {
|
|
2097
|
-
|
|
2098
|
-
this
|
|
2099
|
-
|
|
2100
|
-
Number(e - this.alignment)
|
|
2209
|
+
const s = Math.ceil(
|
|
2210
|
+
Number(t - this.alignment) / Number(this.alignmentMultiple)
|
|
2211
|
+
), u = Math.ceil(
|
|
2212
|
+
Number(e - this.alignment) / Number(this.alignmentMultiple)
|
|
2101
2213
|
);
|
|
2214
|
+
return new J(this, s, u);
|
|
2102
2215
|
}
|
|
2103
2216
|
subBytes(t, e) {
|
|
2104
2217
|
if (t >= 0 && (e == null || e >= this.byteLength.valueOf())) return this;
|
|
2105
2218
|
const s = this.data.subarray(t, e);
|
|
2106
|
-
return new
|
|
2219
|
+
return new v({
|
|
2107
2220
|
data: s,
|
|
2108
2221
|
dataType: this.dataType,
|
|
2109
2222
|
timeRange: this.timeRange,
|
|
@@ -2115,7 +2228,7 @@ class I {
|
|
|
2115
2228
|
sliceSub(t, e, s) {
|
|
2116
2229
|
if (e <= 0 && (s == null || s >= this.length)) return this;
|
|
2117
2230
|
let u;
|
|
2118
|
-
return t ? u = this.data.subarray(e, s) : u = this.data.slice(e, s), new
|
|
2231
|
+
return t ? u = this.data.subarray(e, s) : u = this.data.slice(e, s), new v({
|
|
2119
2232
|
data: u,
|
|
2120
2233
|
dataType: this.dataType,
|
|
2121
2234
|
timeRange: this.timeRange,
|
|
@@ -2130,7 +2243,7 @@ class I {
|
|
|
2130
2243
|
* @returns A new series with the specified alignment.
|
|
2131
2244
|
*/
|
|
2132
2245
|
reAlign(t) {
|
|
2133
|
-
return new
|
|
2246
|
+
return new v({
|
|
2134
2247
|
data: this.buffer,
|
|
2135
2248
|
dataType: this.dataType,
|
|
2136
2249
|
timeRange: w.ZERO,
|
|
@@ -2157,21 +2270,21 @@ class I {
|
|
|
2157
2270
|
return t += "])", t;
|
|
2158
2271
|
}
|
|
2159
2272
|
}
|
|
2160
|
-
const
|
|
2161
|
-
class
|
|
2273
|
+
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);
|
|
2274
|
+
class J {
|
|
2162
2275
|
series;
|
|
2163
2276
|
end;
|
|
2164
2277
|
index;
|
|
2165
2278
|
constructor(t, e, s) {
|
|
2166
2279
|
this.series = t;
|
|
2167
|
-
const u =
|
|
2168
|
-
this.end =
|
|
2280
|
+
const u = x(0, t.length + 1);
|
|
2281
|
+
this.end = k(u, s), this.index = k(u, e);
|
|
2169
2282
|
}
|
|
2170
2283
|
next() {
|
|
2171
2284
|
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
2172
2285
|
}
|
|
2173
2286
|
}
|
|
2174
|
-
class
|
|
2287
|
+
class Bt {
|
|
2175
2288
|
series;
|
|
2176
2289
|
index;
|
|
2177
2290
|
decoder;
|
|
@@ -2184,12 +2297,12 @@ class vt {
|
|
|
2184
2297
|
}
|
|
2185
2298
|
next() {
|
|
2186
2299
|
const t = this.index, e = this.series.data;
|
|
2187
|
-
for (; this.index < e.length && e[this.index] !==
|
|
2300
|
+
for (; this.index < e.length && e[this.index] !== Y; ) this.index++;
|
|
2188
2301
|
const s = this.index;
|
|
2189
2302
|
return t === s ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(t, s)) });
|
|
2190
2303
|
}
|
|
2191
2304
|
}
|
|
2192
|
-
class
|
|
2305
|
+
class V {
|
|
2193
2306
|
wrapped;
|
|
2194
2307
|
static schema = o.record(o.string(), o.unknown());
|
|
2195
2308
|
constructor(t) {
|
|
@@ -2199,27 +2312,27 @@ class $ {
|
|
|
2199
2312
|
const t = this.wrapped.next();
|
|
2200
2313
|
return t.done === !0 ? { done: !0, value: void 0 } : {
|
|
2201
2314
|
done: !1,
|
|
2202
|
-
value:
|
|
2315
|
+
value: $.decodeString(t.value, V.schema)
|
|
2203
2316
|
};
|
|
2204
2317
|
}
|
|
2205
2318
|
}
|
|
2206
|
-
class
|
|
2319
|
+
class Ct {
|
|
2207
2320
|
series;
|
|
2208
2321
|
index;
|
|
2209
2322
|
data;
|
|
2210
2323
|
density;
|
|
2211
2324
|
constructor(t) {
|
|
2212
|
-
if (!t.dataType.equals(
|
|
2325
|
+
if (!t.dataType.equals(n.UUID))
|
|
2213
2326
|
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 =
|
|
2327
|
+
this.series = t, this.index = 0, this.data = new Uint8Array(t.buffer), this.density = n.UUID.density.valueOf();
|
|
2215
2328
|
}
|
|
2216
2329
|
next() {
|
|
2217
2330
|
if (this.index >= this.series.length) return { done: !0, value: void 0 };
|
|
2218
|
-
const t =
|
|
2331
|
+
const t = Z(this.data, this.index * this.density);
|
|
2219
2332
|
return this.index++, { done: !1, value: t };
|
|
2220
2333
|
}
|
|
2221
2334
|
}
|
|
2222
|
-
class
|
|
2335
|
+
class xt {
|
|
2223
2336
|
series;
|
|
2224
2337
|
index;
|
|
2225
2338
|
constructor(t) {
|
|
@@ -2232,7 +2345,7 @@ class At {
|
|
|
2232
2345
|
};
|
|
2233
2346
|
}
|
|
2234
2347
|
}
|
|
2235
|
-
class
|
|
2348
|
+
class Wt {
|
|
2236
2349
|
/** The array of series in this collection */
|
|
2237
2350
|
series;
|
|
2238
2351
|
/**
|
|
@@ -2285,14 +2398,14 @@ class Vt {
|
|
|
2285
2398
|
this.series = t;
|
|
2286
2399
|
}
|
|
2287
2400
|
as(t) {
|
|
2288
|
-
return
|
|
2401
|
+
return tt(t, this.dataType), this;
|
|
2289
2402
|
}
|
|
2290
2403
|
/**
|
|
2291
2404
|
* Returns the data type of the series in this collection. If the collection is empty,
|
|
2292
2405
|
* returns DataType.UNKNOWN.
|
|
2293
2406
|
*/
|
|
2294
2407
|
get dataType() {
|
|
2295
|
-
return this.series.length === 0 ?
|
|
2408
|
+
return this.series.length === 0 ? n.UNKNOWN : this.series[0].dataType;
|
|
2296
2409
|
}
|
|
2297
2410
|
/**
|
|
2298
2411
|
* Returns the combined time range of all series in the collection. If the collection
|
|
@@ -2318,7 +2431,7 @@ class Vt {
|
|
|
2318
2431
|
* series + its length. If the collection is empty, returns bounds.construct(0n, 0n).
|
|
2319
2432
|
*/
|
|
2320
2433
|
get alignmentBounds() {
|
|
2321
|
-
return this.series.length === 0 ?
|
|
2434
|
+
return this.series.length === 0 ? x(0n, 0n) : x(
|
|
2322
2435
|
this.series[0].alignmentBounds.lower,
|
|
2323
2436
|
this.series[this.series.length - 1].alignmentBounds.upper
|
|
2324
2437
|
);
|
|
@@ -2327,7 +2440,7 @@ class Vt {
|
|
|
2327
2440
|
const e = () => new Error(
|
|
2328
2441
|
`cannot push a ${t.dataType.toString()} series to a ${this.dataType.toString()} multi-series`
|
|
2329
2442
|
), s = t.dataType.equals(this.dataType);
|
|
2330
|
-
if (
|
|
2443
|
+
if (st(t)) {
|
|
2331
2444
|
if (this.series.length !== 0 && !s) throw e();
|
|
2332
2445
|
this.series.push(t);
|
|
2333
2446
|
} else {
|
|
@@ -2364,7 +2477,7 @@ class Vt {
|
|
|
2364
2477
|
* @returns An iterator over the specified range.
|
|
2365
2478
|
*/
|
|
2366
2479
|
subIterator(t, e) {
|
|
2367
|
-
return new
|
|
2480
|
+
return new P(this, t, e ?? this.length);
|
|
2368
2481
|
}
|
|
2369
2482
|
/**
|
|
2370
2483
|
* Returns an iterator over a portion of the multi-series based on alignment.
|
|
@@ -2374,28 +2487,32 @@ class Vt {
|
|
|
2374
2487
|
*/
|
|
2375
2488
|
subAlignmentIterator(t, e) {
|
|
2376
2489
|
if (t >= this.alignmentBounds.upper || e <= this.alignmentBounds.lower)
|
|
2377
|
-
return
|
|
2490
|
+
return F;
|
|
2378
2491
|
let s = 0;
|
|
2379
|
-
for (let
|
|
2380
|
-
const
|
|
2381
|
-
if (t <
|
|
2382
|
-
if (t >=
|
|
2383
|
-
else if (R(
|
|
2384
|
-
s +=
|
|
2492
|
+
for (let l = 0; l < this.series.length; l++) {
|
|
2493
|
+
const h = this.series[l];
|
|
2494
|
+
if (t < h.alignment) break;
|
|
2495
|
+
if (t >= h.alignmentBounds.upper) s += h.length;
|
|
2496
|
+
else if (R(h.alignmentBounds, t)) {
|
|
2497
|
+
s += Math.ceil(
|
|
2498
|
+
Number(t - h.alignment) / Number(h.alignmentMultiple)
|
|
2499
|
+
);
|
|
2385
2500
|
break;
|
|
2386
2501
|
}
|
|
2387
2502
|
}
|
|
2388
2503
|
let u = 0;
|
|
2389
|
-
for (let
|
|
2390
|
-
const
|
|
2391
|
-
if (e <
|
|
2392
|
-
if (e >=
|
|
2393
|
-
else if (R(
|
|
2394
|
-
u +=
|
|
2504
|
+
for (let l = 0; l < this.series.length; l++) {
|
|
2505
|
+
const h = this.series[l];
|
|
2506
|
+
if (e < h.alignment) break;
|
|
2507
|
+
if (e >= h.alignmentBounds.upper) u += h.length;
|
|
2508
|
+
else if (R(h.alignmentBounds, e)) {
|
|
2509
|
+
u += Math.ceil(
|
|
2510
|
+
Number(e - h.alignment) / Number(h.alignmentMultiple)
|
|
2511
|
+
);
|
|
2395
2512
|
break;
|
|
2396
2513
|
}
|
|
2397
2514
|
}
|
|
2398
|
-
return new
|
|
2515
|
+
return new P(this, s, u);
|
|
2399
2516
|
}
|
|
2400
2517
|
/**
|
|
2401
2518
|
* Returns an iterator over the specified alignment range and span.
|
|
@@ -2404,19 +2521,19 @@ class Vt {
|
|
|
2404
2521
|
* @returns An iterator over the specified range.
|
|
2405
2522
|
*/
|
|
2406
2523
|
subAlignmentSpanIterator(t, e) {
|
|
2407
|
-
if (t >= this.alignmentBounds.upper) return
|
|
2524
|
+
if (t >= this.alignmentBounds.upper) return F;
|
|
2408
2525
|
e = Math.min(e, Number(this.distance(t, this.alignmentBounds.upper)));
|
|
2409
2526
|
let s = 0;
|
|
2410
2527
|
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 -
|
|
2528
|
+
const l = this.series[u];
|
|
2529
|
+
if (t < l.alignment) break;
|
|
2530
|
+
if (t >= l.alignmentBounds.upper) s += l.length;
|
|
2531
|
+
else if (R(l.alignmentBounds, t)) {
|
|
2532
|
+
s += Number(t - l.alignment);
|
|
2416
2533
|
break;
|
|
2417
2534
|
}
|
|
2418
2535
|
}
|
|
2419
|
-
return new
|
|
2536
|
+
return new P(this, s, s + e);
|
|
2420
2537
|
}
|
|
2421
2538
|
/**
|
|
2422
2539
|
* Updates the WebGL buffer for all series in the collection.
|
|
@@ -2429,13 +2546,13 @@ class Vt {
|
|
|
2429
2546
|
* Returns the bounds containing the minimum and maximum values across all series.
|
|
2430
2547
|
*/
|
|
2431
2548
|
get bounds() {
|
|
2432
|
-
return
|
|
2549
|
+
return it(this.series.map((t) => t.bounds));
|
|
2433
2550
|
}
|
|
2434
2551
|
/**
|
|
2435
2552
|
* Returns the sum of the byte lengths of all series.
|
|
2436
2553
|
*/
|
|
2437
2554
|
get byteLength() {
|
|
2438
|
-
return new
|
|
2555
|
+
return new c(this.series.reduce((t, e) => t + e.byteLength.valueOf(), 0));
|
|
2439
2556
|
}
|
|
2440
2557
|
/**
|
|
2441
2558
|
* Returns a combined typed array containing all data from all series.
|
|
@@ -2456,7 +2573,7 @@ class Vt {
|
|
|
2456
2573
|
*/
|
|
2457
2574
|
traverseAlignment(t, e) {
|
|
2458
2575
|
const s = this.series.map((u) => u.alignmentBounds);
|
|
2459
|
-
return
|
|
2576
|
+
return at(s, t, e);
|
|
2460
2577
|
}
|
|
2461
2578
|
/**
|
|
2462
2579
|
* Acquires a reference to the WebGL buffer for all series.
|
|
@@ -2479,7 +2596,7 @@ class Vt {
|
|
|
2479
2596
|
*/
|
|
2480
2597
|
distance(t, e) {
|
|
2481
2598
|
const s = this.series.map((u) => u.alignmentBounds);
|
|
2482
|
-
return
|
|
2599
|
+
return ut(s, t, e);
|
|
2483
2600
|
}
|
|
2484
2601
|
/**
|
|
2485
2602
|
* Parses a JSON multi-series into an array of values using the provided zod schema.
|
|
@@ -2489,7 +2606,7 @@ class Vt {
|
|
|
2489
2606
|
* @returns An array of values parsed from the JSON series.
|
|
2490
2607
|
*/
|
|
2491
2608
|
parseJSON(t) {
|
|
2492
|
-
if (!this.dataType.equals(
|
|
2609
|
+
if (!this.dataType.equals(n.JSON))
|
|
2493
2610
|
throw new Error("cannot parse non-JSON series as JSON");
|
|
2494
2611
|
return this.series.flatMap((e) => e.parseJSON(t));
|
|
2495
2612
|
}
|
|
@@ -2502,7 +2619,7 @@ class Vt {
|
|
|
2502
2619
|
next() {
|
|
2503
2620
|
return { done: !0, value: void 0 };
|
|
2504
2621
|
}
|
|
2505
|
-
} : new
|
|
2622
|
+
} : new Rt(this.series);
|
|
2506
2623
|
}
|
|
2507
2624
|
/**
|
|
2508
2625
|
* Returns an array of the values in the multi-series as strings.
|
|
@@ -2513,7 +2630,7 @@ class Vt {
|
|
|
2513
2630
|
return this.series.flatMap((t) => t.toStrings());
|
|
2514
2631
|
}
|
|
2515
2632
|
}
|
|
2516
|
-
class
|
|
2633
|
+
class Rt {
|
|
2517
2634
|
series;
|
|
2518
2635
|
seriesIndex;
|
|
2519
2636
|
internal;
|
|
@@ -2528,7 +2645,7 @@ class Et {
|
|
|
2528
2645
|
return this;
|
|
2529
2646
|
}
|
|
2530
2647
|
}
|
|
2531
|
-
class
|
|
2648
|
+
class P {
|
|
2532
2649
|
series;
|
|
2533
2650
|
index;
|
|
2534
2651
|
end;
|
|
@@ -2542,27 +2659,27 @@ class S {
|
|
|
2542
2659
|
return this;
|
|
2543
2660
|
}
|
|
2544
2661
|
}
|
|
2545
|
-
const
|
|
2546
|
-
const t =
|
|
2662
|
+
const j = (a) => {
|
|
2663
|
+
const t = a >> 32n, e = a & 0xffffffffn;
|
|
2547
2664
|
return { domain: t, sample: e };
|
|
2548
2665
|
};
|
|
2549
2666
|
export {
|
|
2550
2667
|
d as D,
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
a,
|
|
2668
|
+
Wt as M,
|
|
2669
|
+
I as R,
|
|
2670
|
+
v as S,
|
|
2671
|
+
r as T,
|
|
2672
|
+
i as a,
|
|
2556
2673
|
w as b,
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2674
|
+
n as c,
|
|
2675
|
+
c as d,
|
|
2676
|
+
z as e,
|
|
2677
|
+
dt as f,
|
|
2678
|
+
T as g,
|
|
2679
|
+
X as h,
|
|
2680
|
+
Et as i,
|
|
2681
|
+
kt as j,
|
|
2682
|
+
Gt as m,
|
|
2683
|
+
Jt as t,
|
|
2684
|
+
jt as u
|
|
2568
2685
|
};
|