@synnaxlabs/x 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +23 -23
- package/dist/binary.cjs +1 -1
- package/dist/binary.js +1 -1
- package/dist/bounds-CCueigU3.js +171 -0
- package/dist/bounds-Cudf5M4H.cjs +1 -0
- package/dist/bounds.cjs +1 -1
- package/dist/bounds.js +1 -1
- package/dist/box-CZVdKCOc.cjs +1 -0
- package/dist/box-hAkmDC3K.js +201 -0
- package/dist/box.cjs +1 -1
- package/dist/box.js +1 -1
- package/dist/caseconv.cjs +1 -1
- package/dist/caseconv.js +1 -1
- package/dist/index-By0n2R_b.cjs +1 -0
- package/dist/{index-DgaYJC35.cjs → index-DQZfhLnw.cjs} +1 -1
- package/dist/{index-Duv1uH08.js → index-q_1Jz5rY.js} +5 -5
- package/dist/{index-B5THJ1eb.js → index-zsix_qnl.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +163 -146
- package/dist/{location-DjcaXEps.js → location-B5rSnQP3.js} +1 -1
- package/dist/{location-gPB1RtfA.cjs → location-YGxhLPDy.cjs} +1 -1
- package/dist/location.cjs +1 -1
- package/dist/location.js +1 -1
- package/dist/{position-DkON65EZ.js → position-BZOTg74V.js} +2 -2
- package/dist/{position-C71OiHiw.cjs → position-CjNCcq8X.cjs} +1 -1
- package/dist/position.cjs +1 -1
- package/dist/position.js +1 -1
- package/dist/{scale-COPgp55a.cjs → scale-BvbW9p2C.cjs} +1 -1
- package/dist/{scale-qw6vRO4s.js → scale-C7_4I3pa.js} +3 -3
- package/dist/scale.cjs +1 -1
- package/dist/scale.js +1 -1
- package/dist/series-BId9slhU.cjs +11 -0
- package/dist/{series-B5eA90Ci.js → series-CZw97Bq2.js} +619 -456
- package/dist/spatial.cjs +1 -1
- package/dist/spatial.js +5 -5
- package/dist/src/caseconv/caseconv.d.ts.map +1 -1
- package/dist/src/deep/path.d.ts +1 -1
- package/dist/src/deep/path.d.ts.map +1 -1
- package/dist/src/math/math.d.ts +26 -6
- package/dist/src/math/math.d.ts.map +1 -1
- package/dist/src/math/math.spec.d.ts +2 -0
- package/dist/src/math/math.spec.d.ts.map +1 -0
- package/dist/src/record.d.ts +4 -0
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/spatial/bounds/bounds.d.ts +204 -2
- package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
- package/dist/src/spatial/box/box.d.ts +4 -4
- package/dist/src/spatial/box/box.d.ts.map +1 -1
- package/dist/src/strings/strings.d.ts +14 -0
- package/dist/src/strings/strings.d.ts.map +1 -1
- package/dist/src/telem/series.d.ts +35 -10
- package/dist/src/telem/series.d.ts.map +1 -1
- package/dist/src/telem/telem.d.ts +12 -10
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/telem.cjs +1 -1
- package/dist/telem.js +1 -1
- package/package.json +9 -9
- package/src/caseconv/caseconv.ts +1 -0
- package/src/deep/path.ts +1 -1
- package/src/math/math.spec.ts +149 -0
- package/src/math/math.ts +60 -9
- package/src/record.ts +5 -0
- package/src/spatial/bounds/bounds.spec.ts +135 -270
- package/src/spatial/bounds/bounds.ts +290 -25
- package/src/spatial/box/box.ts +9 -5
- package/src/strings/strings.spec.ts +33 -1
- package/src/strings/strings.ts +52 -0
- package/src/telem/series.spec.ts +235 -0
- package/src/telem/series.ts +271 -52
- package/src/telem/telem.spec.ts +22 -0
- package/src/telem/telem.ts +44 -20
- package/src/zodutil/zodutil.spec.ts +5 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/bounds-CpboA0q6.js +0 -127
- package/dist/bounds-ZZc1c-_Z.cjs +0 -1
- package/dist/box-BQID-0jO.cjs +0 -1
- package/dist/box-xRqO6NvI.js +0 -202
- package/dist/index-xk130iQA.cjs +0 -1
- package/dist/series-CJ65b1Uz.cjs +0 -11
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var s = (
|
|
1
|
+
var tt = Object.defineProperty;
|
|
2
|
+
var et = (l, t, e) => t in l ? tt(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e;
|
|
3
|
+
var s = (l, t, e) => et(l, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { z as o } from "zod";
|
|
5
|
-
import { J as
|
|
6
|
-
import { s as
|
|
7
|
-
import { n as
|
|
8
|
-
import { c as
|
|
9
|
-
import "./box-
|
|
5
|
+
import { J as $ } from "./index-zsix_qnl.js";
|
|
6
|
+
import { s as nt } from "./index-q_1Jz5rY.js";
|
|
7
|
+
import { n as rt } from "./index-B3BUDIdi.js";
|
|
8
|
+
import { m as R, c as L, a as k, d as D, t as st, e as it } from "./bounds-CCueigU3.js";
|
|
9
|
+
import "./box-hAkmDC3K.js";
|
|
10
10
|
import "./dimensions-D-1PnJVI.js";
|
|
11
11
|
import "./base-DnZzEvvz.js";
|
|
12
|
-
import "./location-
|
|
13
|
-
import "./scale-
|
|
12
|
+
import "./location-B5rSnQP3.js";
|
|
13
|
+
import "./scale-C7_4I3pa.js";
|
|
14
14
|
import "./xy-CrgPnICw.js";
|
|
15
|
-
import { b as
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
for (;
|
|
19
|
-
|
|
20
|
-
return
|
|
15
|
+
import { b as at } from "./zodutil-qNM8aVYC.js";
|
|
16
|
+
let ut = (l, t = 21) => (e = t) => {
|
|
17
|
+
let n = "", i = e;
|
|
18
|
+
for (; i--; )
|
|
19
|
+
n += l[Math.random() * l.length | 0];
|
|
20
|
+
return n;
|
|
21
21
|
};
|
|
22
|
-
const
|
|
22
|
+
const ot = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", X = ut(ot, 11), Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
23
23
|
__proto__: null,
|
|
24
|
-
id:
|
|
25
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
24
|
+
id: X
|
|
25
|
+
}, Symbol.toStringTag, { value: "Module" })), lt = o.enum(["static", "dynamic"]), Q = (l, t) => {
|
|
26
26
|
const e = new m(t);
|
|
27
27
|
if (![
|
|
28
28
|
y.DAY,
|
|
@@ -32,30 +32,30 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
32
32
|
y.MILLISECOND,
|
|
33
33
|
y.MICROSECOND,
|
|
34
34
|
y.NANOSECOND
|
|
35
|
-
].some((
|
|
35
|
+
].some((i) => i.equals(e)))
|
|
36
36
|
throw new Error(
|
|
37
37
|
"Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
|
|
38
38
|
);
|
|
39
|
-
const
|
|
40
|
-
return
|
|
41
|
-
},
|
|
39
|
+
const n = l.valueOf() % e.valueOf();
|
|
40
|
+
return l instanceof m ? new m(n) : new y(n);
|
|
41
|
+
}, a = class a {
|
|
42
42
|
constructor(t, e = "UTC") {
|
|
43
43
|
s(this, "value");
|
|
44
44
|
s(this, "encodeValue", !0);
|
|
45
|
-
if (t == null) this.value =
|
|
45
|
+
if (t == null) this.value = a.now().valueOf();
|
|
46
46
|
else if (t instanceof Date)
|
|
47
|
-
this.value = BigInt(t.getTime()) *
|
|
47
|
+
this.value = BigInt(t.getTime()) * a.MILLISECOND.valueOf();
|
|
48
48
|
else if (typeof t == "string")
|
|
49
|
-
this.value =
|
|
50
|
-
else if (Array.isArray(t)) this.value =
|
|
49
|
+
this.value = a.parseDateTimeString(t, e).valueOf();
|
|
50
|
+
else if (Array.isArray(t)) this.value = a.parseDate(t);
|
|
51
51
|
else {
|
|
52
|
-
let
|
|
53
|
-
t instanceof Number && (t = t.valueOf()), e === "local" && (
|
|
52
|
+
let n = BigInt(0);
|
|
53
|
+
t instanceof Number && (t = t.valueOf()), e === "local" && (n = a.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = Math.trunc(t) : (isNaN(t) && (t = 0), t === 1 / 0 ? t = a.MAX : t = a.MIN)), this.value = BigInt(t.valueOf()) + n;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
static parseDate([t = 1970, e = 1,
|
|
57
|
-
const
|
|
58
|
-
return new
|
|
56
|
+
static parseDate([t = 1970, e = 1, n = 1]) {
|
|
57
|
+
const i = new Date(t, e - 1, n, 0, 0, 0, 0);
|
|
58
|
+
return new a(BigInt(i.getTime()) * a.MILLISECOND.valueOf()).truncate(a.DAY).valueOf();
|
|
59
59
|
}
|
|
60
60
|
encode() {
|
|
61
61
|
return this.value.toString();
|
|
@@ -64,18 +64,18 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
64
64
|
return this.value;
|
|
65
65
|
}
|
|
66
66
|
static parseTimeString(t, e = "UTC") {
|
|
67
|
-
const [
|
|
68
|
-
let
|
|
69
|
-
|
|
70
|
-
let O =
|
|
71
|
-
return e === "local" && (O = O.add(
|
|
67
|
+
const [n, i, c] = t.split(":");
|
|
68
|
+
let h = "00", S = "00";
|
|
69
|
+
c != null && ([h, S] = c.split("."));
|
|
70
|
+
let O = a.hours(parseInt(n ?? "00", 10)).add(a.minutes(parseInt(i ?? "00", 10))).add(a.seconds(parseInt(h ?? "00", 10))).add(a.milliseconds(parseInt(S ?? "00", 10)));
|
|
71
|
+
return e === "local" && (O = O.add(a.utcOffset)), O.valueOf();
|
|
72
72
|
}
|
|
73
73
|
static parseDateTimeString(t, e = "UTC") {
|
|
74
74
|
if (!t.includes("/") && !t.includes("-"))
|
|
75
|
-
return
|
|
76
|
-
const
|
|
77
|
-
return t.includes(":") ||
|
|
78
|
-
BigInt(
|
|
75
|
+
return a.parseTimeString(t, e);
|
|
76
|
+
const n = new Date(t);
|
|
77
|
+
return t.includes(":") || n.setUTCHours(0, 0, 0, 0), new a(
|
|
78
|
+
BigInt(n.getTime()) * a.MILLISECOND.valueOf(),
|
|
79
79
|
e
|
|
80
80
|
).valueOf();
|
|
81
81
|
}
|
|
@@ -100,19 +100,19 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
toISOString(t = "UTC") {
|
|
103
|
-
return t === "UTC" ? this.date().toISOString() : this.sub(
|
|
103
|
+
return t === "UTC" ? this.date().toISOString() : this.sub(a.utcOffset).date().toISOString();
|
|
104
104
|
}
|
|
105
105
|
timeString(t = !1, e = "UTC") {
|
|
106
|
-
const
|
|
107
|
-
return t ?
|
|
106
|
+
const n = this.toISOString(e);
|
|
107
|
+
return t ? n.slice(11, 23) : n.slice(11, 19);
|
|
108
108
|
}
|
|
109
109
|
dateString() {
|
|
110
|
-
const t = this.date(), e = t.toLocaleString("default", { month: "short" }),
|
|
111
|
-
return `${e} ${
|
|
110
|
+
const t = this.date(), e = t.toLocaleString("default", { month: "short" }), n = t.toLocaleString("default", { day: "numeric" });
|
|
111
|
+
return `${e} ${n}`;
|
|
112
112
|
}
|
|
113
113
|
static get utcOffset() {
|
|
114
114
|
return new y(
|
|
115
|
-
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) *
|
|
115
|
+
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * a.MINUTE.valueOf()
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
@@ -121,7 +121,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
121
121
|
* @param other - The other timestamp.
|
|
122
122
|
*/
|
|
123
123
|
static since(t) {
|
|
124
|
-
return new
|
|
124
|
+
return new a().span(t);
|
|
125
125
|
}
|
|
126
126
|
/** @returns A JavaScript Date object representing the TimeStamp. */
|
|
127
127
|
date() {
|
|
@@ -134,7 +134,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
134
134
|
* @returns True if the TimeStamps are equal, false otherwise.
|
|
135
135
|
*/
|
|
136
136
|
equals(t) {
|
|
137
|
-
return this.valueOf() === new
|
|
137
|
+
return this.valueOf() === new a(t).valueOf();
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Creates a TimeSpan representing the duration between the two timestamps.
|
|
@@ -154,7 +154,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
154
154
|
* valid, regardless of the TimeStamp order.
|
|
155
155
|
*/
|
|
156
156
|
range(t) {
|
|
157
|
-
return new
|
|
157
|
+
return new E(this, t).makeValid();
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* Creates a TimeRange starting at the TimeStamp and spanning the given
|
|
@@ -183,7 +183,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
183
183
|
* otherwise.
|
|
184
184
|
*/
|
|
185
185
|
after(t) {
|
|
186
|
-
return this.valueOf() > new
|
|
186
|
+
return this.valueOf() > new a(t).valueOf();
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* Checks if the TimeStamp is after or equal to the given TimeStamp.
|
|
@@ -193,7 +193,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
193
193
|
* false otherwise.
|
|
194
194
|
*/
|
|
195
195
|
afterEq(t) {
|
|
196
|
-
return this.valueOf() >= new
|
|
196
|
+
return this.valueOf() >= new a(t).valueOf();
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
199
|
* Checks if the TimeStamp is before the given TimeStamp.
|
|
@@ -203,7 +203,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
203
203
|
* otherwise.
|
|
204
204
|
*/
|
|
205
205
|
before(t) {
|
|
206
|
-
return this.valueOf() < new
|
|
206
|
+
return this.valueOf() < new a(t).valueOf();
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Checks if TimeStamp is before or equal to the current timestamp.
|
|
@@ -213,7 +213,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
213
213
|
* false otherwise.
|
|
214
214
|
*/
|
|
215
215
|
beforeEq(t) {
|
|
216
|
-
return this.valueOf() <= new
|
|
216
|
+
return this.valueOf() <= new a(t).valueOf();
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
219
|
* Adds a TimeSpan to the TimeStamp.
|
|
@@ -223,7 +223,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
223
223
|
* TimeSpan.
|
|
224
224
|
*/
|
|
225
225
|
add(t) {
|
|
226
|
-
return new
|
|
226
|
+
return new a(this.valueOf() + BigInt(t.valueOf()));
|
|
227
227
|
}
|
|
228
228
|
/**
|
|
229
229
|
* Subtracts a TimeSpan from the TimeStamp.
|
|
@@ -233,13 +233,13 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
233
233
|
* TimeSpan.
|
|
234
234
|
*/
|
|
235
235
|
sub(t) {
|
|
236
|
-
return new
|
|
236
|
+
return new a(this.valueOf() - BigInt(t.valueOf()));
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
239
|
* @returns The number of milliseconds since the unix epoch.
|
|
240
240
|
*/
|
|
241
241
|
milliseconds() {
|
|
242
|
-
return Number(this.valueOf()) / Number(
|
|
242
|
+
return Number(this.valueOf()) / Number(a.MILLISECOND.valueOf());
|
|
243
243
|
}
|
|
244
244
|
toString() {
|
|
245
245
|
return this.date().toISOString();
|
|
@@ -256,11 +256,11 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
256
256
|
* @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
|
|
257
257
|
*/
|
|
258
258
|
remainder(t) {
|
|
259
|
-
return
|
|
259
|
+
return Q(this, t);
|
|
260
260
|
}
|
|
261
261
|
/** @returns true if the day portion TimeStamp is today, false otherwise. */
|
|
262
262
|
get isToday() {
|
|
263
|
-
return this.truncate(y.DAY).equals(
|
|
263
|
+
return this.truncate(y.DAY).equals(a.now().truncate(y.DAY));
|
|
264
264
|
}
|
|
265
265
|
truncate(t) {
|
|
266
266
|
return this.sub(this.remainder(t));
|
|
@@ -271,78 +271,84 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
|
|
|
271
271
|
* JavaScript can do).
|
|
272
272
|
*/
|
|
273
273
|
static now() {
|
|
274
|
-
return new
|
|
274
|
+
return new a(/* @__PURE__ */ new Date());
|
|
275
275
|
}
|
|
276
276
|
static max(...t) {
|
|
277
|
-
let e =
|
|
278
|
-
for (const
|
|
279
|
-
const
|
|
280
|
-
|
|
277
|
+
let e = a.MIN;
|
|
278
|
+
for (const n of t) {
|
|
279
|
+
const i = new a(n);
|
|
280
|
+
i.after(e) && (e = i);
|
|
281
281
|
}
|
|
282
282
|
return e;
|
|
283
283
|
}
|
|
284
284
|
static min(...t) {
|
|
285
|
-
let e =
|
|
286
|
-
for (const
|
|
287
|
-
const
|
|
288
|
-
|
|
285
|
+
let e = a.MAX;
|
|
286
|
+
for (const n of t) {
|
|
287
|
+
const i = new a(n);
|
|
288
|
+
i.before(e) && (e = i);
|
|
289
289
|
}
|
|
290
290
|
return e;
|
|
291
291
|
}
|
|
292
292
|
/** @returns a new TimeStamp n nanoseconds after the unix epoch */
|
|
293
293
|
static nanoseconds(t) {
|
|
294
|
-
return new
|
|
294
|
+
return new a(t);
|
|
295
295
|
}
|
|
296
296
|
/** @returns a new TimeStamp n microseconds after the unix epoch */
|
|
297
297
|
static microseconds(t) {
|
|
298
|
-
return
|
|
298
|
+
return a.nanoseconds(t * 1e3);
|
|
299
299
|
}
|
|
300
300
|
/** @returns a new TimeStamp n milliseconds after the unix epoch */
|
|
301
301
|
static milliseconds(t) {
|
|
302
|
-
return
|
|
302
|
+
return a.microseconds(t * 1e3);
|
|
303
303
|
}
|
|
304
304
|
/** @returns a new TimeStamp n seconds after the unix epoch */
|
|
305
305
|
static seconds(t) {
|
|
306
|
-
return
|
|
306
|
+
return a.milliseconds(t * 1e3);
|
|
307
307
|
}
|
|
308
308
|
/** @returns a new TimeStamp n minutes after the unix epoch */
|
|
309
309
|
static minutes(t) {
|
|
310
|
-
return
|
|
310
|
+
return a.seconds(t * 60);
|
|
311
311
|
}
|
|
312
312
|
/** @returns a new TimeStamp n hours after the unix epoch */
|
|
313
313
|
static hours(t) {
|
|
314
|
-
return
|
|
314
|
+
return a.minutes(t * 60);
|
|
315
315
|
}
|
|
316
316
|
/** @returns a new TimeStamp n days after the unix epoch */
|
|
317
317
|
static days(t) {
|
|
318
|
-
return
|
|
318
|
+
return a.hours(t * 24);
|
|
319
319
|
}
|
|
320
320
|
};
|
|
321
321
|
/* One nanosecond after the unix epoch */
|
|
322
|
-
s(
|
|
323
|
-
s(
|
|
324
|
-
s(
|
|
325
|
-
s(
|
|
326
|
-
s(
|
|
327
|
-
s(
|
|
328
|
-
s(
|
|
329
|
-
s(
|
|
330
|
-
s(
|
|
331
|
-
s(
|
|
332
|
-
s(
|
|
333
|
-
o.object({ value: o.bigint() }).transform((t) => new
|
|
334
|
-
o.string().transform((t) => new
|
|
335
|
-
o.instanceof(Number).transform((t) => new
|
|
336
|
-
o.number().transform((t) => new
|
|
337
|
-
o.instanceof(
|
|
322
|
+
s(a, "NANOSECOND", a.nanoseconds(1)), /** One microsecond after the unix epoch */
|
|
323
|
+
s(a, "MICROSECOND", a.microseconds(1)), /** One millisecond after the unix epoch */
|
|
324
|
+
s(a, "MILLISECOND", a.milliseconds(1)), /** One second after the unix epoch */
|
|
325
|
+
s(a, "SECOND", a.seconds(1)), /** One minute after the unix epoch */
|
|
326
|
+
s(a, "MINUTE", a.minutes(1)), /** One hour after the unix epoch */
|
|
327
|
+
s(a, "HOUR", a.hours(1)), /** One day after the unix epoch */
|
|
328
|
+
s(a, "DAY", a.days(1)), /** The maximum possible value for a timestamp */
|
|
329
|
+
s(a, "MAX", new a((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
|
|
330
|
+
s(a, "MIN", new a(0)), /** The unix epoch */
|
|
331
|
+
s(a, "ZERO", new a(0)), /** A zod schema for validating timestamps */
|
|
332
|
+
s(a, "z", o.union([
|
|
333
|
+
o.object({ value: o.bigint() }).transform((t) => new a(t.value)),
|
|
334
|
+
o.string().transform((t) => new a(BigInt(t))),
|
|
335
|
+
o.instanceof(Number).transform((t) => new a(t)),
|
|
336
|
+
o.number().transform((t) => new a(t)),
|
|
337
|
+
o.instanceof(a)
|
|
338
338
|
]));
|
|
339
|
-
let m =
|
|
340
|
-
const
|
|
339
|
+
let m = a;
|
|
340
|
+
const u = class u {
|
|
341
341
|
constructor(t) {
|
|
342
342
|
s(this, "value");
|
|
343
343
|
s(this, "encodeValue", !0);
|
|
344
344
|
typeof t == "number" && (t = Math.trunc(t.valueOf())), this.value = BigInt(t.valueOf());
|
|
345
345
|
}
|
|
346
|
+
static fromSeconds(t) {
|
|
347
|
+
return t instanceof u ? t : t instanceof P ? t.period : t instanceof m ? new u(t) : ["number", "bigint"].includes(typeof t) ? u.seconds(t) : new u(t);
|
|
348
|
+
}
|
|
349
|
+
static fromMilliseconds(t) {
|
|
350
|
+
return t instanceof u ? t : t instanceof P ? t.period : t instanceof m ? new u(t) : ["number", "bigint"].includes(typeof t) ? u.milliseconds(t) : new u(t);
|
|
351
|
+
}
|
|
346
352
|
encode() {
|
|
347
353
|
return this.value.toString();
|
|
348
354
|
}
|
|
@@ -350,52 +356,52 @@ const a = class a {
|
|
|
350
356
|
return this.value;
|
|
351
357
|
}
|
|
352
358
|
lessThan(t) {
|
|
353
|
-
return this.valueOf() < new
|
|
359
|
+
return this.valueOf() < new u(t).valueOf();
|
|
354
360
|
}
|
|
355
361
|
greaterThan(t) {
|
|
356
|
-
return this.valueOf() > new
|
|
362
|
+
return this.valueOf() > new u(t).valueOf();
|
|
357
363
|
}
|
|
358
364
|
lessThanOrEqual(t) {
|
|
359
|
-
return this.valueOf() <= new
|
|
365
|
+
return this.valueOf() <= new u(t).valueOf();
|
|
360
366
|
}
|
|
361
367
|
greaterThanOrEqual(t) {
|
|
362
|
-
return this.valueOf() >= new
|
|
368
|
+
return this.valueOf() >= new u(t).valueOf();
|
|
363
369
|
}
|
|
364
370
|
remainder(t) {
|
|
365
|
-
return
|
|
371
|
+
return Q(this, t);
|
|
366
372
|
}
|
|
367
373
|
truncate(t) {
|
|
368
|
-
return new
|
|
374
|
+
return new u(
|
|
369
375
|
BigInt(Math.trunc(Number(this.valueOf() / t.valueOf()))) * t.valueOf()
|
|
370
376
|
);
|
|
371
377
|
}
|
|
372
378
|
toString() {
|
|
373
|
-
const t = this.truncate(
|
|
379
|
+
const t = this.truncate(u.DAY), e = this.truncate(u.HOUR), n = this.truncate(u.MINUTE), i = this.truncate(u.SECOND), c = this.truncate(u.MILLISECOND), h = this.truncate(u.MICROSECOND), S = this.truncate(u.NANOSECOND), O = t, N = e.sub(t), p = n.sub(e), f = i.sub(n), M = c.sub(i), U = h.sub(c), Z = S.sub(h);
|
|
374
380
|
let A = "";
|
|
375
|
-
return O.isZero || (A += `${O.days}d `), N.isZero || (A += `${N.hours}h `), p.isZero || (A += `${p.minutes}m `),
|
|
381
|
+
return O.isZero || (A += `${O.days}d `), N.isZero || (A += `${N.hours}h `), p.isZero || (A += `${p.minutes}m `), f.isZero || (A += `${f.seconds}s `), M.isZero || (A += `${M.milliseconds}ms `), U.isZero || (A += `${U.microseconds}µs `), Z.isZero || (A += `${Z.nanoseconds}ns`), A.trim();
|
|
376
382
|
}
|
|
377
383
|
/** @returns the decimal number of days in the timespan */
|
|
378
384
|
get days() {
|
|
379
|
-
return Number(this.valueOf()) / Number(
|
|
385
|
+
return Number(this.valueOf()) / Number(u.DAY.valueOf());
|
|
380
386
|
}
|
|
381
387
|
/** @returns the decimal number of hours in the timespan */
|
|
382
388
|
get hours() {
|
|
383
|
-
return Number(this.valueOf()) / Number(
|
|
389
|
+
return Number(this.valueOf()) / Number(u.HOUR.valueOf());
|
|
384
390
|
}
|
|
385
391
|
/** @returns the decimal number of minutes in the timespan */
|
|
386
392
|
get minutes() {
|
|
387
|
-
return Number(this.valueOf()) / Number(
|
|
393
|
+
return Number(this.valueOf()) / Number(u.MINUTE.valueOf());
|
|
388
394
|
}
|
|
389
395
|
/** @returns The number of seconds in the TimeSpan. */
|
|
390
396
|
get seconds() {
|
|
391
|
-
return Number(this.valueOf()) / Number(
|
|
397
|
+
return Number(this.valueOf()) / Number(u.SECOND.valueOf());
|
|
392
398
|
}
|
|
393
399
|
/** @returns The number of milliseconds in the TimeSpan. */
|
|
394
400
|
get milliseconds() {
|
|
395
|
-
return Number(this.valueOf()) / Number(
|
|
401
|
+
return Number(this.valueOf()) / Number(u.MILLISECOND.valueOf());
|
|
396
402
|
}
|
|
397
403
|
get microseconds() {
|
|
398
|
-
return Number(this.valueOf()) / Number(
|
|
404
|
+
return Number(this.valueOf()) / Number(u.MICROSECOND.valueOf());
|
|
399
405
|
}
|
|
400
406
|
get nanoseconds() {
|
|
401
407
|
return Number(this.valueOf());
|
|
@@ -414,7 +420,7 @@ const a = class a {
|
|
|
414
420
|
* @returns True if the TimeSpans are equal, false otherwise.
|
|
415
421
|
*/
|
|
416
422
|
equals(t) {
|
|
417
|
-
return this.valueOf() === new
|
|
423
|
+
return this.valueOf() === new u(t).valueOf();
|
|
418
424
|
}
|
|
419
425
|
/**
|
|
420
426
|
* Adds a TimeSpan to the TimeSpan.
|
|
@@ -422,7 +428,7 @@ const a = class a {
|
|
|
422
428
|
* @returns A new TimeSpan representing the sum of the two TimeSpans.
|
|
423
429
|
*/
|
|
424
430
|
add(t) {
|
|
425
|
-
return new
|
|
431
|
+
return new u(this.valueOf() + new u(t).valueOf());
|
|
426
432
|
}
|
|
427
433
|
/**
|
|
428
434
|
* Creates a TimeSpan representing the duration between the two timestamps.
|
|
@@ -430,7 +436,7 @@ const a = class a {
|
|
|
430
436
|
* @param other
|
|
431
437
|
*/
|
|
432
438
|
sub(t) {
|
|
433
|
-
return new
|
|
439
|
+
return new u(this.valueOf() - new u(t).valueOf());
|
|
434
440
|
}
|
|
435
441
|
/**
|
|
436
442
|
* Creates a TimeSpan representing the given number of nanoseconds.
|
|
@@ -439,7 +445,7 @@ const a = class a {
|
|
|
439
445
|
* @returns A TimeSpan representing the given number of nanoseconds.
|
|
440
446
|
*/
|
|
441
447
|
static nanoseconds(t = 1) {
|
|
442
|
-
return new
|
|
448
|
+
return new u(t);
|
|
443
449
|
}
|
|
444
450
|
/**
|
|
445
451
|
* Creates a TimeSpan representing the given number of microseconds.
|
|
@@ -448,7 +454,7 @@ const a = class a {
|
|
|
448
454
|
* @returns A TimeSpan representing the given number of microseconds.
|
|
449
455
|
*/
|
|
450
456
|
static microseconds(t = 1) {
|
|
451
|
-
return
|
|
457
|
+
return u.nanoseconds(R(t, 1e3));
|
|
452
458
|
}
|
|
453
459
|
/**
|
|
454
460
|
* Creates a TimeSpan representing the given number of milliseconds.
|
|
@@ -457,7 +463,7 @@ const a = class a {
|
|
|
457
463
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
458
464
|
*/
|
|
459
465
|
static milliseconds(t = 1) {
|
|
460
|
-
return
|
|
466
|
+
return u.microseconds(R(t, 1e3));
|
|
461
467
|
}
|
|
462
468
|
/**
|
|
463
469
|
* Creates a TimeSpan representing the given number of seconds.
|
|
@@ -466,7 +472,7 @@ const a = class a {
|
|
|
466
472
|
* @returns A TimeSpan representing the given number of seconds.
|
|
467
473
|
*/
|
|
468
474
|
static seconds(t = 1) {
|
|
469
|
-
return
|
|
475
|
+
return u.milliseconds(R(t, 1e3));
|
|
470
476
|
}
|
|
471
477
|
/**
|
|
472
478
|
* Creates a TimeSpan representing the given number of minutes.
|
|
@@ -474,8 +480,8 @@ const a = class a {
|
|
|
474
480
|
* @param value - The number of minutes.
|
|
475
481
|
* @returns A TimeSpan representing the given number of minutes.
|
|
476
482
|
*/
|
|
477
|
-
static minutes(t) {
|
|
478
|
-
return
|
|
483
|
+
static minutes(t = 1) {
|
|
484
|
+
return u.seconds(R(t, 60));
|
|
479
485
|
}
|
|
480
486
|
/**
|
|
481
487
|
* Creates a TimeSpan representing the given number of hours.
|
|
@@ -484,7 +490,7 @@ const a = class a {
|
|
|
484
490
|
* @returns A TimeSpan representing the given number of hours.
|
|
485
491
|
*/
|
|
486
492
|
static hours(t) {
|
|
487
|
-
return
|
|
493
|
+
return u.minutes(R(t, 60));
|
|
488
494
|
}
|
|
489
495
|
/**
|
|
490
496
|
* Creates a TimeSpan representing the given number of days.
|
|
@@ -493,28 +499,28 @@ const a = class a {
|
|
|
493
499
|
* @returns A TimeSpan representing the given number of days.
|
|
494
500
|
*/
|
|
495
501
|
static days(t) {
|
|
496
|
-
return
|
|
502
|
+
return u.hours(R(t, 24));
|
|
497
503
|
}
|
|
498
504
|
};
|
|
499
505
|
/** A nanosecond. */
|
|
500
|
-
s(
|
|
501
|
-
s(
|
|
502
|
-
s(
|
|
503
|
-
s(
|
|
504
|
-
s(
|
|
505
|
-
s(
|
|
506
|
-
s(
|
|
507
|
-
s(
|
|
508
|
-
s(
|
|
509
|
-
s(
|
|
510
|
-
s(
|
|
511
|
-
o.object({ value: o.bigint() }).transform((t) => new
|
|
512
|
-
o.string().transform((t) => new
|
|
513
|
-
o.instanceof(Number).transform((t) => new
|
|
514
|
-
o.number().transform((t) => new
|
|
515
|
-
o.instanceof(
|
|
506
|
+
s(u, "NANOSECOND", u.nanoseconds(1)), /** A microsecond. */
|
|
507
|
+
s(u, "MICROSECOND", u.microseconds(1)), /** A millisecond. */
|
|
508
|
+
s(u, "MILLISECOND", u.milliseconds(1)), /** A second. */
|
|
509
|
+
s(u, "SECOND", u.seconds(1)), /** A minute. */
|
|
510
|
+
s(u, "MINUTE", u.minutes(1)), /** Represents an hour. */
|
|
511
|
+
s(u, "HOUR", u.hours(1)), /** Represents a day. */
|
|
512
|
+
s(u, "DAY", u.days(1)), /** The maximum possible value for a TimeSpan. */
|
|
513
|
+
s(u, "MAX", new u((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
|
|
514
|
+
s(u, "MIN", new u(0)), /** The zero value for a TimeSpan. */
|
|
515
|
+
s(u, "ZERO", new u(0)), /** A zod schema for validating and transforming timespans */
|
|
516
|
+
s(u, "z", o.union([
|
|
517
|
+
o.object({ value: o.bigint() }).transform((t) => new u(t.value)),
|
|
518
|
+
o.string().transform((t) => new u(BigInt(t))),
|
|
519
|
+
o.instanceof(Number).transform((t) => new u(t)),
|
|
520
|
+
o.number().transform((t) => new u(t)),
|
|
521
|
+
o.instanceof(u)
|
|
516
522
|
]));
|
|
517
|
-
let y =
|
|
523
|
+
let y = u;
|
|
518
524
|
const v = class v extends Number {
|
|
519
525
|
constructor(t) {
|
|
520
526
|
t instanceof Number ? super(t.valueOf()) : super(t);
|
|
@@ -598,7 +604,7 @@ s(v, "z", o.union([
|
|
|
598
604
|
o.instanceof(Number).transform((t) => new v(t)),
|
|
599
605
|
o.instanceof(v)
|
|
600
606
|
]));
|
|
601
|
-
let
|
|
607
|
+
let P = v;
|
|
602
608
|
const w = class w extends Number {
|
|
603
609
|
/**
|
|
604
610
|
* Creates a Density representing the given number of bytes per value.
|
|
@@ -614,7 +620,7 @@ const w = class w extends Number {
|
|
|
614
620
|
return t.valueOf() / this.valueOf();
|
|
615
621
|
}
|
|
616
622
|
size(t) {
|
|
617
|
-
return new
|
|
623
|
+
return new x(t * this.valueOf());
|
|
618
624
|
}
|
|
619
625
|
};
|
|
620
626
|
/** Unknown/Invalid Density. */
|
|
@@ -630,7 +636,7 @@ s(w, "z", o.union([
|
|
|
630
636
|
o.instanceof(w)
|
|
631
637
|
]));
|
|
632
638
|
let b = w;
|
|
633
|
-
const
|
|
639
|
+
const T = class T {
|
|
634
640
|
/**
|
|
635
641
|
* Creates a TimeRange from the given start and end TimeStamps.
|
|
636
642
|
*
|
|
@@ -698,7 +704,7 @@ const I = class I {
|
|
|
698
704
|
* @returns A TimeRange with the start and end swapped.
|
|
699
705
|
*/
|
|
700
706
|
swap() {
|
|
701
|
-
return new
|
|
707
|
+
return new T(this.end, this.start);
|
|
702
708
|
}
|
|
703
709
|
/**
|
|
704
710
|
* Checks if the TimeRange is equal to the given TimeRange.
|
|
@@ -725,52 +731,52 @@ const I = class I {
|
|
|
725
731
|
*/
|
|
726
732
|
overlapsWith(t, e = y.ZERO) {
|
|
727
733
|
t = t.makeValid();
|
|
728
|
-
const
|
|
734
|
+
const n = this.makeValid();
|
|
729
735
|
if (this.equals(t)) return !0;
|
|
730
|
-
if (t.end.equals(
|
|
731
|
-
const
|
|
732
|
-
return
|
|
736
|
+
if (t.end.equals(n.start) || n.end.equals(t.start)) return !1;
|
|
737
|
+
const i = m.max(n.start, t.start), c = m.min(n.end, t.end);
|
|
738
|
+
return c.before(i) ? !1 : new y(c.sub(i)).greaterThanOrEqual(e);
|
|
733
739
|
}
|
|
734
740
|
roughlyEquals(t, e) {
|
|
735
|
-
let
|
|
736
|
-
return
|
|
741
|
+
let n = this.start.sub(t.start).valueOf(), i = this.end.sub(t.end).valueOf();
|
|
742
|
+
return n < 0 && (n = -n), i < 0 && (i = -i), n <= e.valueOf() && i <= e.valueOf();
|
|
737
743
|
}
|
|
738
744
|
contains(t) {
|
|
739
|
-
return t instanceof
|
|
745
|
+
return t instanceof T ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
|
|
740
746
|
}
|
|
741
747
|
boundBy(t) {
|
|
742
|
-
const e = new
|
|
748
|
+
const e = new T(this.start, this.end);
|
|
743
749
|
return t.start.after(this.start) && (e.start = t.start), t.start.after(this.end) && (e.end = t.start), t.end.before(this.end) && (e.end = t.end), t.end.before(this.start) && (e.start = t.end), e;
|
|
744
750
|
}
|
|
745
751
|
};
|
|
746
752
|
/** The maximum possible time range. */
|
|
747
|
-
s(
|
|
748
|
-
s(
|
|
749
|
-
s(
|
|
750
|
-
s(
|
|
751
|
-
o.object({ start: m.z, end: m.z }).transform((t) => new
|
|
752
|
-
o.instanceof(
|
|
753
|
+
s(T, "MAX", new T(m.MIN, m.MAX)), /** The minimum possible time range. */
|
|
754
|
+
s(T, "MIN", new T(m.MAX, m.MIN)), /** A zero time range. */
|
|
755
|
+
s(T, "ZERO", new T(m.ZERO, m.ZERO)), /** A zod schema for validating and transforming time ranges */
|
|
756
|
+
s(T, "z", o.union([
|
|
757
|
+
o.object({ start: m.z, end: m.z }).transform((t) => new T(t.start, t.end)),
|
|
758
|
+
o.instanceof(T)
|
|
753
759
|
]));
|
|
754
|
-
let
|
|
755
|
-
const
|
|
760
|
+
let E = T;
|
|
761
|
+
const r = class r extends String {
|
|
756
762
|
constructor(t) {
|
|
757
|
-
if (t instanceof
|
|
763
|
+
if (t instanceof r || typeof t == "string" || typeof t.valueOf() == "string") {
|
|
758
764
|
super(t.valueOf());
|
|
759
765
|
return;
|
|
760
766
|
} else {
|
|
761
|
-
const e =
|
|
767
|
+
const e = r.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
|
|
762
768
|
if (e != null) {
|
|
763
769
|
super(e.valueOf());
|
|
764
770
|
return;
|
|
765
771
|
}
|
|
766
772
|
}
|
|
767
|
-
throw super(
|
|
773
|
+
throw super(r.UNKNOWN.valueOf()), new Error(`unable to find data type for ${t.toString()}`);
|
|
768
774
|
}
|
|
769
775
|
/**
|
|
770
776
|
* @returns the TypedArray constructor for the DataType.
|
|
771
777
|
*/
|
|
772
778
|
get Array() {
|
|
773
|
-
const t =
|
|
779
|
+
const t = r.ARRAY_CONSTRUCTORS.get(this.toString());
|
|
774
780
|
if (t == null)
|
|
775
781
|
throw new Error(`unable to find array constructor for ${this.valueOf()}`);
|
|
776
782
|
return t;
|
|
@@ -792,10 +798,10 @@ const n = class n extends String {
|
|
|
792
798
|
return this.valueOf();
|
|
793
799
|
}
|
|
794
800
|
get isVariable() {
|
|
795
|
-
return this.equals(
|
|
801
|
+
return this.equals(r.JSON) || this.equals(r.STRING);
|
|
796
802
|
}
|
|
797
803
|
get isNumeric() {
|
|
798
|
-
return !this.isVariable && !this.equals(
|
|
804
|
+
return !this.isVariable && !this.equals(r.UUID);
|
|
799
805
|
}
|
|
800
806
|
get isInteger() {
|
|
801
807
|
return this.toString().startsWith("int");
|
|
@@ -804,7 +810,7 @@ const n = class n extends String {
|
|
|
804
810
|
return this.toString().startsWith("float");
|
|
805
811
|
}
|
|
806
812
|
get density() {
|
|
807
|
-
const t =
|
|
813
|
+
const t = r.DENSITIES.get(this.toString());
|
|
808
814
|
if (t == null) throw new Error(`unable to find density for ${this.valueOf()}`);
|
|
809
815
|
return t;
|
|
810
816
|
}
|
|
@@ -829,92 +835,92 @@ const n = class n extends String {
|
|
|
829
835
|
return this.toString();
|
|
830
836
|
}
|
|
831
837
|
get usesBigInt() {
|
|
832
|
-
return
|
|
838
|
+
return r.BIG_INT_TYPES.some((t) => t.equals(this));
|
|
833
839
|
}
|
|
834
840
|
};
|
|
835
841
|
/** Represents an Unknown/Invalid DataType. */
|
|
836
|
-
s(
|
|
837
|
-
s(
|
|
838
|
-
s(
|
|
839
|
-
s(
|
|
840
|
-
s(
|
|
841
|
-
s(
|
|
842
|
-
s(
|
|
843
|
-
s(
|
|
844
|
-
s(
|
|
845
|
-
s(
|
|
846
|
-
s(
|
|
847
|
-
s(
|
|
848
|
-
s(
|
|
849
|
-
s(
|
|
842
|
+
s(r, "UNKNOWN", new r("unknown")), /** Represents a 64-bit floating point value. */
|
|
843
|
+
s(r, "FLOAT64", new r("float64")), /** Represents a 32-bit floating point value. */
|
|
844
|
+
s(r, "FLOAT32", new r("float32")), /** Represents a 64-bit signed integer value. */
|
|
845
|
+
s(r, "INT64", new r("int64")), /** Represents a 32-bit signed integer value. */
|
|
846
|
+
s(r, "INT32", new r("int32")), /** Represents a 16-bit signed integer value. */
|
|
847
|
+
s(r, "INT16", new r("int16")), /** Represents a 8-bit signed integer value. */
|
|
848
|
+
s(r, "INT8", new r("int8")), /** Represents a 64-bit unsigned integer value. */
|
|
849
|
+
s(r, "UINT64", new r("uint64")), /** Represents a 32-bit unsigned integer value. */
|
|
850
|
+
s(r, "UINT32", new r("uint32")), /** Represents a 16-bit unsigned integer value. */
|
|
851
|
+
s(r, "UINT16", new r("uint16")), /** Represents a 8-bit unsigned integer value. */
|
|
852
|
+
s(r, "UINT8", new r("uint8")), /** Represents a boolean value. Alias for UINT8. */
|
|
853
|
+
s(r, "BOOLEAN", r.UINT8), /** Represents a 64-bit unix epoch. */
|
|
854
|
+
s(r, "TIMESTAMP", new r("timestamp")), /** Represents a UUID data type */
|
|
855
|
+
s(r, "UUID", new r("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
|
|
850
856
|
* by a newline character. */
|
|
851
|
-
s(
|
|
857
|
+
s(r, "STRING", new r("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
|
|
852
858
|
* newline character. */
|
|
853
|
-
s(
|
|
854
|
-
[
|
|
855
|
-
[
|
|
856
|
-
[
|
|
857
|
-
[
|
|
858
|
-
[
|
|
859
|
-
[
|
|
860
|
-
[
|
|
861
|
-
[
|
|
862
|
-
[
|
|
863
|
-
[
|
|
864
|
-
[
|
|
865
|
-
[
|
|
866
|
-
[
|
|
867
|
-
[
|
|
868
|
-
])), s(
|
|
869
|
-
[Uint8Array.name,
|
|
870
|
-
[Uint16Array.name,
|
|
871
|
-
[Uint32Array.name,
|
|
872
|
-
[BigUint64Array.name,
|
|
873
|
-
[Float32Array.name,
|
|
874
|
-
[Float64Array.name,
|
|
875
|
-
[Int8Array.name,
|
|
876
|
-
[Int16Array.name,
|
|
877
|
-
[Int32Array.name,
|
|
878
|
-
[BigInt64Array.name,
|
|
879
|
-
])), s(
|
|
880
|
-
[
|
|
881
|
-
[
|
|
882
|
-
[
|
|
883
|
-
[
|
|
884
|
-
[
|
|
885
|
-
[
|
|
886
|
-
[
|
|
887
|
-
[
|
|
888
|
-
[
|
|
889
|
-
[
|
|
890
|
-
[
|
|
891
|
-
[
|
|
892
|
-
[
|
|
893
|
-
[
|
|
859
|
+
s(r, "JSON", new r("json")), s(r, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
|
|
860
|
+
[r.UINT8.toString(), Uint8Array],
|
|
861
|
+
[r.UINT16.toString(), Uint16Array],
|
|
862
|
+
[r.UINT32.toString(), Uint32Array],
|
|
863
|
+
[r.UINT64.toString(), BigUint64Array],
|
|
864
|
+
[r.FLOAT32.toString(), Float32Array],
|
|
865
|
+
[r.FLOAT64.toString(), Float64Array],
|
|
866
|
+
[r.INT8.toString(), Int8Array],
|
|
867
|
+
[r.INT16.toString(), Int16Array],
|
|
868
|
+
[r.INT32.toString(), Int32Array],
|
|
869
|
+
[r.INT64.toString(), BigInt64Array],
|
|
870
|
+
[r.TIMESTAMP.toString(), BigInt64Array],
|
|
871
|
+
[r.STRING.toString(), Uint8Array],
|
|
872
|
+
[r.JSON.toString(), Uint8Array],
|
|
873
|
+
[r.UUID.toString(), Uint8Array]
|
|
874
|
+
])), s(r, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
|
|
875
|
+
[Uint8Array.name, r.UINT8],
|
|
876
|
+
[Uint16Array.name, r.UINT16],
|
|
877
|
+
[Uint32Array.name, r.UINT32],
|
|
878
|
+
[BigUint64Array.name, r.UINT64],
|
|
879
|
+
[Float32Array.name, r.FLOAT32],
|
|
880
|
+
[Float64Array.name, r.FLOAT64],
|
|
881
|
+
[Int8Array.name, r.INT8],
|
|
882
|
+
[Int16Array.name, r.INT16],
|
|
883
|
+
[Int32Array.name, r.INT32],
|
|
884
|
+
[BigInt64Array.name, r.INT64]
|
|
885
|
+
])), s(r, "DENSITIES", /* @__PURE__ */ new Map([
|
|
886
|
+
[r.UINT8.toString(), b.BIT8],
|
|
887
|
+
[r.UINT16.toString(), b.BIT16],
|
|
888
|
+
[r.UINT32.toString(), b.BIT32],
|
|
889
|
+
[r.UINT64.toString(), b.BIT64],
|
|
890
|
+
[r.FLOAT32.toString(), b.BIT32],
|
|
891
|
+
[r.FLOAT64.toString(), b.BIT64],
|
|
892
|
+
[r.INT8.toString(), b.BIT8],
|
|
893
|
+
[r.INT16.toString(), b.BIT16],
|
|
894
|
+
[r.INT32.toString(), b.BIT32],
|
|
895
|
+
[r.INT64.toString(), b.BIT64],
|
|
896
|
+
[r.TIMESTAMP.toString(), b.BIT64],
|
|
897
|
+
[r.STRING.toString(), b.UNKNOWN],
|
|
898
|
+
[r.JSON.toString(), b.UNKNOWN],
|
|
899
|
+
[r.UUID.toString(), b.BIT128]
|
|
894
900
|
])), /** All the data types. */
|
|
895
|
-
s(
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
]), s(
|
|
912
|
-
s(
|
|
913
|
-
o.string().transform((t) => new
|
|
914
|
-
o.instanceof(
|
|
901
|
+
s(r, "ALL", [
|
|
902
|
+
r.UNKNOWN,
|
|
903
|
+
r.FLOAT64,
|
|
904
|
+
r.FLOAT32,
|
|
905
|
+
r.INT64,
|
|
906
|
+
r.INT32,
|
|
907
|
+
r.INT16,
|
|
908
|
+
r.INT8,
|
|
909
|
+
r.UINT64,
|
|
910
|
+
r.UINT32,
|
|
911
|
+
r.UINT16,
|
|
912
|
+
r.UINT8,
|
|
913
|
+
r.TIMESTAMP,
|
|
914
|
+
r.UUID,
|
|
915
|
+
r.STRING,
|
|
916
|
+
r.JSON
|
|
917
|
+
]), s(r, "BIG_INT_TYPES", [r.INT64, r.UINT64, r.TIMESTAMP]), /** A zod schema for a DataType. */
|
|
918
|
+
s(r, "z", o.union([
|
|
919
|
+
o.string().transform((t) => new r(t)),
|
|
920
|
+
o.instanceof(r)
|
|
915
921
|
]));
|
|
916
|
-
let
|
|
917
|
-
const
|
|
922
|
+
let g = r;
|
|
923
|
+
const d = class d extends Number {
|
|
918
924
|
constructor(t) {
|
|
919
925
|
super(t.valueOf());
|
|
920
926
|
}
|
|
@@ -927,33 +933,33 @@ const l = class l extends Number {
|
|
|
927
933
|
return this.valueOf() < t.valueOf();
|
|
928
934
|
}
|
|
929
935
|
add(t) {
|
|
930
|
-
return
|
|
936
|
+
return d.bytes(this.valueOf() + t.valueOf());
|
|
931
937
|
}
|
|
932
938
|
sub(t) {
|
|
933
|
-
return
|
|
939
|
+
return d.bytes(this.valueOf() - t.valueOf());
|
|
934
940
|
}
|
|
935
941
|
truncate(t) {
|
|
936
|
-
return new
|
|
942
|
+
return new d(Math.trunc(this.valueOf() / t.valueOf()) * t.valueOf());
|
|
937
943
|
}
|
|
938
944
|
remainder(t) {
|
|
939
|
-
return
|
|
945
|
+
return d.bytes(this.valueOf() % t.valueOf());
|
|
940
946
|
}
|
|
941
947
|
get gigabytes() {
|
|
942
|
-
return this.valueOf() /
|
|
948
|
+
return this.valueOf() / d.GIGABYTE.valueOf();
|
|
943
949
|
}
|
|
944
950
|
get megabytes() {
|
|
945
|
-
return this.valueOf() /
|
|
951
|
+
return this.valueOf() / d.MEGABYTE.valueOf();
|
|
946
952
|
}
|
|
947
953
|
get kilobytes() {
|
|
948
|
-
return this.valueOf() /
|
|
954
|
+
return this.valueOf() / d.KILOBYTE.valueOf();
|
|
949
955
|
}
|
|
950
956
|
get terabytes() {
|
|
951
|
-
return this.valueOf() /
|
|
957
|
+
return this.valueOf() / d.TERABYTE.valueOf();
|
|
952
958
|
}
|
|
953
959
|
toString() {
|
|
954
|
-
const t = this.truncate(
|
|
955
|
-
let
|
|
956
|
-
return
|
|
960
|
+
const t = this.truncate(d.TERABYTE), e = this.truncate(d.GIGABYTE), n = this.truncate(d.MEGABYTE), i = this.truncate(d.KILOBYTE), c = this.truncate(d.BYTE), h = t, S = e.sub(t), O = n.sub(e), N = i.sub(n), p = c.sub(i);
|
|
961
|
+
let f = "";
|
|
962
|
+
return h.isZero || (f += `${h.terabytes}TB `), S.isZero || (f += `${S.gigabytes}GB `), O.isZero || (f += `${O.megabytes}MB `), N.isZero || (f += `${N.kilobytes}KB `), (!p.isZero || f === "") && (f += `${p.valueOf()}B`), f.trim();
|
|
957
963
|
}
|
|
958
964
|
/**
|
|
959
965
|
* Creates a Size from the given number of bytes.
|
|
@@ -962,7 +968,7 @@ const l = class l extends Number {
|
|
|
962
968
|
* @returns A Size representing the given number of bytes.
|
|
963
969
|
*/
|
|
964
970
|
static bytes(t = 1) {
|
|
965
|
-
return new
|
|
971
|
+
return new d(t);
|
|
966
972
|
}
|
|
967
973
|
/**
|
|
968
974
|
* Creates a Size from the given number if kilobytes.
|
|
@@ -971,7 +977,7 @@ const l = class l extends Number {
|
|
|
971
977
|
* @returns A Size representing the given number of kilobytes.
|
|
972
978
|
*/
|
|
973
979
|
static kilobytes(t = 1) {
|
|
974
|
-
return
|
|
980
|
+
return d.bytes(t.valueOf() * 1e3);
|
|
975
981
|
}
|
|
976
982
|
/**
|
|
977
983
|
* Creates a Size from the given number of megabytes.
|
|
@@ -980,7 +986,7 @@ const l = class l extends Number {
|
|
|
980
986
|
* @returns A Size representing the given number of megabytes.
|
|
981
987
|
*/
|
|
982
988
|
static megabytes(t = 1) {
|
|
983
|
-
return
|
|
989
|
+
return d.kilobytes(t.valueOf() * 1e3);
|
|
984
990
|
}
|
|
985
991
|
/**
|
|
986
992
|
* Creates a Size from the given number of gigabytes.
|
|
@@ -989,7 +995,7 @@ const l = class l extends Number {
|
|
|
989
995
|
* @returns A Size representing the given number of gigabytes.
|
|
990
996
|
*/
|
|
991
997
|
static gigabytes(t = 1) {
|
|
992
|
-
return
|
|
998
|
+
return d.megabytes(t.valueOf() * 1e3);
|
|
993
999
|
}
|
|
994
1000
|
/**
|
|
995
1001
|
* Creates a Size from the given number of terabytes.
|
|
@@ -998,25 +1004,25 @@ const l = class l extends Number {
|
|
|
998
1004
|
* @returns A Size representing the given number of terabytes.
|
|
999
1005
|
*/
|
|
1000
1006
|
static terabytes(t) {
|
|
1001
|
-
return
|
|
1007
|
+
return d.gigabytes(t.valueOf() * 1e3);
|
|
1002
1008
|
}
|
|
1003
1009
|
get isZero() {
|
|
1004
1010
|
return this.valueOf() === 0;
|
|
1005
1011
|
}
|
|
1006
1012
|
};
|
|
1007
1013
|
/** A single byte */
|
|
1008
|
-
s(
|
|
1009
|
-
s(
|
|
1010
|
-
s(
|
|
1011
|
-
s(
|
|
1012
|
-
s(
|
|
1013
|
-
s(
|
|
1014
|
-
s(
|
|
1015
|
-
o.number().transform((t) => new
|
|
1016
|
-
o.instanceof(
|
|
1014
|
+
s(d, "BYTE", new d(1)), /** A kilobyte */
|
|
1015
|
+
s(d, "KILOBYTE", d.kilobytes(1)), /** A megabyte */
|
|
1016
|
+
s(d, "MEGABYTE", d.megabytes(1)), /** A gigabyte */
|
|
1017
|
+
s(d, "GIGABYTE", d.gigabytes(1)), /** A terabyte. */
|
|
1018
|
+
s(d, "TERABYTE", d.terabytes(1)), /** The zero value for Size */
|
|
1019
|
+
s(d, "ZERO", new d(0)), /** A zod schema for a Size. */
|
|
1020
|
+
s(d, "z", o.union([
|
|
1021
|
+
o.number().transform((t) => new d(t)),
|
|
1022
|
+
o.instanceof(d)
|
|
1017
1023
|
]));
|
|
1018
|
-
let
|
|
1019
|
-
const
|
|
1024
|
+
let x = d;
|
|
1025
|
+
const xt = o.union([
|
|
1020
1026
|
o.instanceof(Uint8Array),
|
|
1021
1027
|
o.instanceof(Uint16Array),
|
|
1022
1028
|
o.instanceof(Uint32Array),
|
|
@@ -1027,14 +1033,17 @@ const St = o.union([
|
|
|
1027
1033
|
o.instanceof(Int16Array),
|
|
1028
1034
|
o.instanceof(Int32Array),
|
|
1029
1035
|
o.instanceof(BigInt64Array)
|
|
1030
|
-
]),
|
|
1031
|
-
const t = typeof
|
|
1032
|
-
return t === "string" || t === "number" || t === "boolean" || t === "bigint" ||
|
|
1033
|
-
},
|
|
1034
|
-
(
|
|
1035
|
-
|
|
1036
|
+
]), _ = (l) => {
|
|
1037
|
+
const t = typeof l;
|
|
1038
|
+
return t === "string" || t === "number" || t === "boolean" || t === "bigint" || l instanceof m || l instanceof y || l instanceof Date;
|
|
1039
|
+
}, ct = (l, t, e, n = 0) => l.usesBigInt && !t.usesBigInt ? Number(e) - Number(n) : !l.usesBigInt && t.usesBigInt ? BigInt(e.valueOf()) - BigInt(n.valueOf()) : C(e, -n).valueOf(), ft = (l) => l == null ? !1 : Array.isArray(l) || l instanceof ArrayBuffer || ArrayBuffer.isView(l) && !(l instanceof DataView) || l instanceof V ? !0 : _(l), B = -1, q = {
|
|
1040
|
+
[Symbol.iterator]: () => q,
|
|
1041
|
+
next: () => ({ done: !0, value: void 0 })
|
|
1042
|
+
}, ht = o.string().transform(
|
|
1043
|
+
(l) => new Uint8Array(
|
|
1044
|
+
atob(l).split("").map((t) => t.charCodeAt(0))
|
|
1036
1045
|
).buffer
|
|
1037
|
-
),
|
|
1046
|
+
), dt = o.union([o.null(), o.undefined()]).transform(() => new Uint8Array().buffer), Y = 10, I = class I {
|
|
1038
1047
|
constructor(t) {
|
|
1039
1048
|
s(this, "key", "");
|
|
1040
1049
|
s(this, "isSynnaxSeries", !0);
|
|
@@ -1059,104 +1068,107 @@ const St = o.union([
|
|
|
1059
1068
|
/** A cached maximum value. */
|
|
1060
1069
|
s(this, "_cachedMax");
|
|
1061
1070
|
/** The write position of the buffer. */
|
|
1062
|
-
s(this, "writePos",
|
|
1071
|
+
s(this, "writePos", B);
|
|
1063
1072
|
/** Tracks the number of entities currently using this array. */
|
|
1064
1073
|
s(this, "_refCount", 0);
|
|
1074
|
+
/** Caches the length of the array for variable length data types. */
|
|
1065
1075
|
s(this, "_cachedLength");
|
|
1066
|
-
|
|
1076
|
+
/** Caches the indexes of the array for variable length data types. */
|
|
1077
|
+
s(this, "_cachedIndexes");
|
|
1078
|
+
ft(t) && (t = { data: t });
|
|
1067
1079
|
const {
|
|
1068
1080
|
dataType: e,
|
|
1069
|
-
timeRange:
|
|
1070
|
-
sampleOffset:
|
|
1071
|
-
glBufferUsage:
|
|
1072
|
-
alignment:
|
|
1073
|
-
key: S =
|
|
1081
|
+
timeRange: n,
|
|
1082
|
+
sampleOffset: i = 0,
|
|
1083
|
+
glBufferUsage: c = "static",
|
|
1084
|
+
alignment: h = 0n,
|
|
1085
|
+
key: S = X()
|
|
1074
1086
|
} = t, O = t.data ?? [];
|
|
1075
|
-
if (O instanceof
|
|
1076
|
-
const
|
|
1077
|
-
this.key =
|
|
1087
|
+
if (O instanceof I || typeof O == "object" && "isSynnaxSeries" in O && O.isSynnaxSeries === !0) {
|
|
1088
|
+
const f = O;
|
|
1089
|
+
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._cachedMin = f._cachedMin, this._cachedMax = f._cachedMax, this.writePos = f.writePos, this._refCount = f._refCount, this._cachedLength = f._cachedLength;
|
|
1078
1090
|
return;
|
|
1079
1091
|
}
|
|
1080
|
-
const N =
|
|
1081
|
-
if (e != null) this.dataType = new
|
|
1092
|
+
const N = _(O), p = Array.isArray(O);
|
|
1093
|
+
if (e != null) this.dataType = new g(e);
|
|
1082
1094
|
else {
|
|
1083
1095
|
if (O instanceof ArrayBuffer)
|
|
1084
1096
|
throw new Error(
|
|
1085
1097
|
"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
|
|
1086
1098
|
);
|
|
1087
1099
|
if (p || N) {
|
|
1088
|
-
let
|
|
1100
|
+
let f = O;
|
|
1089
1101
|
if (!N) {
|
|
1090
1102
|
if (O.length === 0)
|
|
1091
1103
|
throw new Error(
|
|
1092
1104
|
"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
|
|
1093
1105
|
);
|
|
1094
|
-
|
|
1106
|
+
f = O[0];
|
|
1095
1107
|
}
|
|
1096
|
-
if (typeof
|
|
1097
|
-
else if (typeof
|
|
1098
|
-
else if (typeof
|
|
1099
|
-
else if (typeof
|
|
1100
|
-
else if (
|
|
1101
|
-
this.dataType =
|
|
1102
|
-
else if (typeof
|
|
1108
|
+
if (typeof f == "string") this.dataType = g.STRING;
|
|
1109
|
+
else if (typeof f == "number") this.dataType = g.FLOAT64;
|
|
1110
|
+
else if (typeof f == "bigint") this.dataType = g.INT64;
|
|
1111
|
+
else if (typeof f == "boolean") this.dataType = g.BOOLEAN;
|
|
1112
|
+
else if (f instanceof m || f instanceof Date || f instanceof m)
|
|
1113
|
+
this.dataType = g.TIMESTAMP;
|
|
1114
|
+
else if (typeof f == "object") this.dataType = g.JSON;
|
|
1103
1115
|
else
|
|
1104
1116
|
throw new Error(
|
|
1105
|
-
`cannot infer data type of ${typeof
|
|
1117
|
+
`cannot infer data type of ${typeof f} when constructing a Series from a JS array`
|
|
1106
1118
|
);
|
|
1107
|
-
} else this.dataType = new
|
|
1119
|
+
} else this.dataType = new g(O);
|
|
1108
1120
|
}
|
|
1109
1121
|
if (!p && !N) this._data = O;
|
|
1110
1122
|
else {
|
|
1111
|
-
let
|
|
1112
|
-
const M =
|
|
1113
|
-
(M instanceof m || M instanceof Date || M instanceof y) && (
|
|
1123
|
+
let f = N ? [O] : O;
|
|
1124
|
+
const M = f[0];
|
|
1125
|
+
(M instanceof m || M instanceof Date || M instanceof y) && (f = f.map((U) => new m(U).valueOf())), this.dataType.equals(g.STRING) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(f.join(`
|
|
1114
1126
|
`) + `
|
|
1115
|
-
`)) : this.dataType.equals(
|
|
1116
|
-
|
|
1127
|
+
`)) : this.dataType.equals(g.JSON) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(
|
|
1128
|
+
f.map((U) => $.encodeString(U)).join(`
|
|
1117
1129
|
`) + `
|
|
1118
1130
|
`
|
|
1119
|
-
)) : this._data = new this.dataType.Array(
|
|
1131
|
+
)) : this._data = new this.dataType.Array(f).buffer;
|
|
1120
1132
|
}
|
|
1121
|
-
this.key = S, this.alignment =
|
|
1133
|
+
this.key = S, this.alignment = h, this.sampleOffset = i ?? 0, this._timeRange = n, this.gl = {
|
|
1122
1134
|
control: null,
|
|
1123
1135
|
buffer: null,
|
|
1124
1136
|
prevBuffer: 0,
|
|
1125
|
-
bufferUsage:
|
|
1137
|
+
bufferUsage: c
|
|
1126
1138
|
};
|
|
1127
1139
|
}
|
|
1128
|
-
static alloc({ capacity: t, dataType: e, ...
|
|
1140
|
+
static alloc({ capacity: t, dataType: e, ...n }) {
|
|
1129
1141
|
if (t === 0)
|
|
1130
1142
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
1131
|
-
const
|
|
1132
|
-
data:
|
|
1143
|
+
const i = new new g(e).Array(t), c = new I({
|
|
1144
|
+
data: i.buffer,
|
|
1133
1145
|
dataType: e,
|
|
1134
|
-
...
|
|
1146
|
+
...n
|
|
1135
1147
|
});
|
|
1136
|
-
return
|
|
1148
|
+
return c.writePos = 0, c;
|
|
1137
1149
|
}
|
|
1138
|
-
static generateTimestamps(t, e,
|
|
1139
|
-
const
|
|
1140
|
-
for (let
|
|
1141
|
-
|
|
1142
|
-
return new
|
|
1150
|
+
static generateTimestamps(t, e, n) {
|
|
1151
|
+
const i = n.spanRange(e.span(t)), c = new BigInt64Array(t);
|
|
1152
|
+
for (let h = 0; h < t; h++)
|
|
1153
|
+
c[h] = BigInt(n.add(e.span(h)).valueOf());
|
|
1154
|
+
return new I({ data: c, dataType: g.TIMESTAMP, timeRange: i });
|
|
1143
1155
|
}
|
|
1144
1156
|
get refCount() {
|
|
1145
1157
|
return this._refCount;
|
|
1146
1158
|
}
|
|
1147
1159
|
static fromStrings(t, e) {
|
|
1148
|
-
const
|
|
1160
|
+
const n = new TextEncoder().encode(t.join(`
|
|
1149
1161
|
`) + `
|
|
1150
1162
|
`);
|
|
1151
|
-
return new
|
|
1163
|
+
return new I({ data: n, dataType: g.STRING, timeRange: e });
|
|
1152
1164
|
}
|
|
1153
1165
|
static fromJSON(t, e) {
|
|
1154
|
-
const
|
|
1155
|
-
t.map((
|
|
1166
|
+
const n = new TextEncoder().encode(
|
|
1167
|
+
t.map((i) => $.encodeString(i)).join(`
|
|
1156
1168
|
`) + `
|
|
1157
1169
|
`
|
|
1158
1170
|
);
|
|
1159
|
-
return new
|
|
1171
|
+
return new I({ data: n, dataType: g.JSON, timeRange: e });
|
|
1160
1172
|
}
|
|
1161
1173
|
acquire(t) {
|
|
1162
1174
|
this._refCount++, t != null && this.updateGLBuffer(t);
|
|
@@ -1178,45 +1190,56 @@ const St = o.union([
|
|
|
1178
1190
|
write(t) {
|
|
1179
1191
|
if (!t.dataType.equals(this.dataType))
|
|
1180
1192
|
throw new Error("buffer must be of the same type as this array");
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1193
|
+
return this.dataType.isVariable ? this.writeVariable(t) : this.writeFixed(t);
|
|
1194
|
+
}
|
|
1195
|
+
writeVariable(t) {
|
|
1196
|
+
if (this.writePos === B) return 0;
|
|
1197
|
+
const e = this.byteCapacity.valueOf() - this.writePos, n = t.subBytes(0, e);
|
|
1198
|
+
return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this._cachedLength != null && (this._cachedLength += n.length, this.calculateCachedLength()), n.length;
|
|
1199
|
+
}
|
|
1200
|
+
writeFixed(t) {
|
|
1201
|
+
if (this.writePos === B) return 0;
|
|
1202
|
+
const e = this.capacity - this.writePos, n = t.sub(0, e);
|
|
1203
|
+
return this.writeToUnderlyingData(n), this._cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
|
|
1204
|
+
}
|
|
1205
|
+
writeToUnderlyingData(t) {
|
|
1206
|
+
this.underlyingData.set(
|
|
1207
|
+
t.data,
|
|
1185
1208
|
this.writePos
|
|
1186
|
-
)
|
|
1209
|
+
);
|
|
1187
1210
|
}
|
|
1188
1211
|
/** @returns the underlying buffer backing this array. */
|
|
1189
1212
|
get buffer() {
|
|
1190
|
-
return this._data;
|
|
1213
|
+
return this._data instanceof ArrayBuffer || this._data instanceof SharedArrayBuffer ? this._data : this._data.buffer;
|
|
1191
1214
|
}
|
|
1192
1215
|
get underlyingData() {
|
|
1193
1216
|
return new this.dataType.Array(this._data);
|
|
1194
1217
|
}
|
|
1195
1218
|
/** @returns a native typed array with the proper data type. */
|
|
1196
1219
|
get data() {
|
|
1197
|
-
return this.writePos ===
|
|
1220
|
+
return this.writePos === B ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
|
|
1198
1221
|
}
|
|
1199
1222
|
toStrings() {
|
|
1200
|
-
if (!this.dataType.matches(
|
|
1223
|
+
if (!this.dataType.matches(g.STRING, g.UUID))
|
|
1201
1224
|
throw new Error("cannot convert non-string series to strings");
|
|
1202
|
-
return new TextDecoder().decode(this.
|
|
1225
|
+
return new TextDecoder().decode(this.underlyingData).split(`
|
|
1203
1226
|
`).slice(0, -1);
|
|
1204
1227
|
}
|
|
1205
1228
|
toUUIDs() {
|
|
1206
|
-
if (!this.dataType.equals(
|
|
1229
|
+
if (!this.dataType.equals(g.UUID))
|
|
1207
1230
|
throw new Error("cannot convert non-uuid series to uuids");
|
|
1208
|
-
const t =
|
|
1209
|
-
for (let
|
|
1210
|
-
const
|
|
1211
|
-
e[
|
|
1231
|
+
const t = g.UUID.density.valueOf(), e = Array(this.length);
|
|
1232
|
+
for (let n = 0; n < this.length; n++) {
|
|
1233
|
+
const i = this.underlyingData.slice(n * t, (n + 1) * t), c = Array.from(new Uint8Array(i), (h) => h.toString(16).padStart(2, "0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
|
|
1234
|
+
e[n] = c;
|
|
1212
1235
|
}
|
|
1213
1236
|
return e;
|
|
1214
1237
|
}
|
|
1215
1238
|
parseJSON(t) {
|
|
1216
|
-
if (!this.dataType.equals(
|
|
1239
|
+
if (!this.dataType.equals(g.JSON))
|
|
1217
1240
|
throw new Error("cannot convert non-string series to strings");
|
|
1218
|
-
return new TextDecoder().decode(this.
|
|
1219
|
-
`).slice(0, -1).map((e) => t.parse(
|
|
1241
|
+
return new TextDecoder().decode(this.underlyingData).split(`
|
|
1242
|
+
`).slice(0, -1).map((e) => t.parse($.decodeString(e)));
|
|
1220
1243
|
}
|
|
1221
1244
|
/** @returns the time range of this array. */
|
|
1222
1245
|
get timeRange() {
|
|
@@ -1225,27 +1248,28 @@ const St = o.union([
|
|
|
1225
1248
|
}
|
|
1226
1249
|
/** @returns the capacity of the series in bytes. */
|
|
1227
1250
|
get byteCapacity() {
|
|
1228
|
-
return new
|
|
1251
|
+
return new x(this.underlyingData.byteLength);
|
|
1229
1252
|
}
|
|
1230
1253
|
/** @returns the capacity of the series in samples. */
|
|
1231
1254
|
get capacity() {
|
|
1232
|
-
return this.dataType.density.length(this.byteCapacity);
|
|
1255
|
+
return this.dataType.isVariable ? this.byteCapacity.valueOf() : this.dataType.density.length(this.byteCapacity);
|
|
1233
1256
|
}
|
|
1234
1257
|
/** @returns the length of the series in bytes. */
|
|
1235
1258
|
get byteLength() {
|
|
1236
|
-
return this.writePos ===
|
|
1259
|
+
return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new x(this.writePos) : this.dataType.density.size(this.writePos);
|
|
1237
1260
|
}
|
|
1238
1261
|
/** @returns the number of samples in this array. */
|
|
1239
1262
|
get length() {
|
|
1240
|
-
return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos ===
|
|
1263
|
+
return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === B ? this.data.length : this.writePos;
|
|
1241
1264
|
}
|
|
1242
1265
|
calculateCachedLength() {
|
|
1243
1266
|
if (!this.dataType.isVariable)
|
|
1244
1267
|
throw new Error("cannot calculate length of a non-variable length data type");
|
|
1245
1268
|
let t = 0;
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1269
|
+
const e = [0];
|
|
1270
|
+
return this.data.forEach((n, i) => {
|
|
1271
|
+
n === Y && (t++, e.push(i + 1));
|
|
1272
|
+
}), this._cachedIndexes = e, this._cachedLength = t, t;
|
|
1249
1273
|
}
|
|
1250
1274
|
/**
|
|
1251
1275
|
* Creates a new array with a different data type.
|
|
@@ -1258,11 +1282,11 @@ const St = o.union([
|
|
|
1258
1282
|
*/
|
|
1259
1283
|
convert(t, e = 0) {
|
|
1260
1284
|
if (this.dataType.equals(t)) return this;
|
|
1261
|
-
const
|
|
1262
|
-
for (let
|
|
1263
|
-
|
|
1264
|
-
return new
|
|
1265
|
-
data:
|
|
1285
|
+
const n = new t.Array(this.length);
|
|
1286
|
+
for (let i = 0; i < this.length; i++)
|
|
1287
|
+
n[i] = ct(this.dataType, t, this.data[i], e);
|
|
1288
|
+
return new I({
|
|
1289
|
+
data: n.buffer,
|
|
1266
1290
|
dataType: t,
|
|
1267
1291
|
timeRange: this._timeRange,
|
|
1268
1292
|
sampleOffset: e,
|
|
@@ -1272,14 +1296,14 @@ const St = o.union([
|
|
|
1272
1296
|
}
|
|
1273
1297
|
calcRawMax() {
|
|
1274
1298
|
if (this.length === 0) return -1 / 0;
|
|
1275
|
-
if (this.dataType.equals(
|
|
1299
|
+
if (this.dataType.equals(g.TIMESTAMP))
|
|
1276
1300
|
this._cachedMax = this.data[this.data.length - 1];
|
|
1277
1301
|
else if (this.dataType.usesBigInt) {
|
|
1278
1302
|
const t = this.data;
|
|
1279
|
-
this._cachedMax = t.reduce((e,
|
|
1303
|
+
this._cachedMax = t.reduce((e, n) => e > n ? e : n);
|
|
1280
1304
|
} else {
|
|
1281
1305
|
const t = this.data;
|
|
1282
|
-
this._cachedMax = t.reduce((e,
|
|
1306
|
+
this._cachedMax = t.reduce((e, n) => e > n ? e : n);
|
|
1283
1307
|
}
|
|
1284
1308
|
return this._cachedMax;
|
|
1285
1309
|
}
|
|
@@ -1287,18 +1311,18 @@ const St = o.union([
|
|
|
1287
1311
|
get max() {
|
|
1288
1312
|
if (this.dataType.isVariable)
|
|
1289
1313
|
throw new Error("cannot calculate maximum on a variable length data type");
|
|
1290
|
-
return this.writePos === 0 ? -1 / 0 : (this._cachedMax == null && (this._cachedMax = this.calcRawMax()),
|
|
1314
|
+
return this.writePos === 0 ? -1 / 0 : (this._cachedMax == null && (this._cachedMax = this.calcRawMax()), C(this._cachedMax, this.sampleOffset));
|
|
1291
1315
|
}
|
|
1292
1316
|
calcRawMin() {
|
|
1293
1317
|
if (this.length === 0) return 1 / 0;
|
|
1294
|
-
if (this.dataType.equals(
|
|
1318
|
+
if (this.dataType.equals(g.TIMESTAMP))
|
|
1295
1319
|
this._cachedMin = this.data[0];
|
|
1296
1320
|
else if (this.dataType.usesBigInt) {
|
|
1297
1321
|
const t = this.data;
|
|
1298
|
-
this._cachedMin = t.reduce((e,
|
|
1322
|
+
this._cachedMin = t.reduce((e, n) => e < n ? e : n);
|
|
1299
1323
|
} else {
|
|
1300
1324
|
const t = this.data;
|
|
1301
|
-
this._cachedMin = t.reduce((e,
|
|
1325
|
+
this._cachedMin = t.reduce((e, n) => e < n ? e : n);
|
|
1302
1326
|
}
|
|
1303
1327
|
return this._cachedMin;
|
|
1304
1328
|
}
|
|
@@ -1306,11 +1330,11 @@ const St = o.union([
|
|
|
1306
1330
|
get min() {
|
|
1307
1331
|
if (this.dataType.isVariable)
|
|
1308
1332
|
throw new Error("cannot calculate minimum on a variable length data type");
|
|
1309
|
-
return this.writePos === 0 ? 1 / 0 : (this._cachedMin == null && (this._cachedMin = this.calcRawMin()),
|
|
1333
|
+
return this.writePos === 0 ? 1 / 0 : (this._cachedMin == null && (this._cachedMin = this.calcRawMin()), C(this._cachedMin, this.sampleOffset));
|
|
1310
1334
|
}
|
|
1311
1335
|
/** @returns the bounds of this array. */
|
|
1312
1336
|
get bounds() {
|
|
1313
|
-
return
|
|
1337
|
+
return L(Number(this.min), Number(this.max));
|
|
1314
1338
|
}
|
|
1315
1339
|
maybeRecomputeMinMax(t) {
|
|
1316
1340
|
if (this._cachedMin != null) {
|
|
@@ -1326,36 +1350,48 @@ const St = o.union([
|
|
|
1326
1350
|
this.max, this.min;
|
|
1327
1351
|
}
|
|
1328
1352
|
get range() {
|
|
1329
|
-
return
|
|
1353
|
+
return C(this.max, -this.min);
|
|
1354
|
+
}
|
|
1355
|
+
atAlignment(t, e) {
|
|
1356
|
+
const n = Number(t - this.alignment);
|
|
1357
|
+
if (n < 0 || n >= this.length) {
|
|
1358
|
+
if (e === !0) throw new Error(`[series] - no value at index ${n}`);
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
return this.at(n, e);
|
|
1330
1362
|
}
|
|
1331
1363
|
at(t, e) {
|
|
1332
1364
|
if (this.dataType.isVariable) return this.atVariable(t, e ?? !1);
|
|
1333
1365
|
t < 0 && (t = this.length + t);
|
|
1334
|
-
const
|
|
1335
|
-
if (
|
|
1366
|
+
const n = this.data[t];
|
|
1367
|
+
if (n == null) {
|
|
1336
1368
|
if (e === !0) throw new Error(`[series] - no value at index ${t}`);
|
|
1337
1369
|
return;
|
|
1338
1370
|
}
|
|
1339
|
-
return
|
|
1371
|
+
return C(n, this.sampleOffset);
|
|
1340
1372
|
}
|
|
1341
1373
|
atVariable(t, e) {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1374
|
+
let n = 0, i = 0;
|
|
1375
|
+
if (this._cachedIndexes != null)
|
|
1376
|
+
n = this._cachedIndexes[t], i = this._cachedIndexes[t + 1] - 1;
|
|
1377
|
+
else {
|
|
1378
|
+
t < 0 && (t = this.length + t);
|
|
1379
|
+
for (let h = 0; h < this.data.length; h++)
|
|
1380
|
+
if (this.data[h] === Y) {
|
|
1381
|
+
if (t === 0) {
|
|
1382
|
+
i = h;
|
|
1383
|
+
break;
|
|
1384
|
+
}
|
|
1385
|
+
n = h + 1, t--;
|
|
1349
1386
|
}
|
|
1350
|
-
|
|
1387
|
+
if (i === 0 && (i = this.data.length), n >= i || t > 0) {
|
|
1388
|
+
if (e) throw new Error(`[series] - no value at index ${t}`);
|
|
1389
|
+
return;
|
|
1351
1390
|
}
|
|
1352
|
-
if (u === 0 && (u = this.data.length), r >= u || t > 0) {
|
|
1353
|
-
if (e) throw new Error(`[series] - no value at index ${t}`);
|
|
1354
|
-
return;
|
|
1355
1391
|
}
|
|
1356
|
-
const
|
|
1357
|
-
return this.dataType.equals(
|
|
1358
|
-
JSON.parse(new TextDecoder().decode(
|
|
1392
|
+
const c = this.data.slice(n, i);
|
|
1393
|
+
return this.dataType.equals(g.STRING) ? new TextDecoder().decode(c) : nt(
|
|
1394
|
+
JSON.parse(new TextDecoder().decode(c))
|
|
1359
1395
|
);
|
|
1360
1396
|
}
|
|
1361
1397
|
/**
|
|
@@ -1364,34 +1400,34 @@ const St = o.union([
|
|
|
1364
1400
|
* @param value the value to search for.
|
|
1365
1401
|
*/
|
|
1366
1402
|
binarySearch(t) {
|
|
1367
|
-
let e = 0,
|
|
1368
|
-
const
|
|
1369
|
-
for (; e <=
|
|
1370
|
-
const
|
|
1371
|
-
if (
|
|
1372
|
-
|
|
1403
|
+
let e = 0, n = this.length - 1;
|
|
1404
|
+
const i = rt(t);
|
|
1405
|
+
for (; e <= n; ) {
|
|
1406
|
+
const c = Math.floor((e + n) / 2), h = i(this.at(c, !0), t);
|
|
1407
|
+
if (h === 0) return c;
|
|
1408
|
+
h < 0 ? e = c + 1 : n = c - 1;
|
|
1373
1409
|
}
|
|
1374
1410
|
return e;
|
|
1375
1411
|
}
|
|
1376
1412
|
updateGLBuffer(t) {
|
|
1377
|
-
if (this.gl.control = t, !this.dataType.equals(
|
|
1413
|
+
if (this.gl.control = t, !this.dataType.equals(g.FLOAT32))
|
|
1378
1414
|
throw new Error("Only FLOAT32 arrays can be used in WebGL");
|
|
1379
|
-
const { buffer: e, bufferUsage:
|
|
1380
|
-
if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !==
|
|
1381
|
-
if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !==
|
|
1382
|
-
|
|
1383
|
-
const
|
|
1384
|
-
t.bufferSubData(t.ARRAY_BUFFER,
|
|
1415
|
+
const { buffer: e, bufferUsage: n, prevBuffer: i } = this.gl;
|
|
1416
|
+
if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== i)
|
|
1417
|
+
if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !== B) {
|
|
1418
|
+
i === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
|
|
1419
|
+
const c = this.dataType.density.size(i).valueOf(), h = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
|
|
1420
|
+
t.bufferSubData(t.ARRAY_BUFFER, c, h.buffer), this.gl.prevBuffer = this.writePos;
|
|
1385
1421
|
} else
|
|
1386
1422
|
t.bufferData(
|
|
1387
1423
|
t.ARRAY_BUFFER,
|
|
1388
|
-
this.
|
|
1389
|
-
|
|
1390
|
-
), this.gl.prevBuffer =
|
|
1424
|
+
this.underlyingData,
|
|
1425
|
+
n === "static" ? t.STATIC_DRAW : t.DYNAMIC_DRAW
|
|
1426
|
+
), this.gl.prevBuffer = B;
|
|
1391
1427
|
}
|
|
1392
1428
|
as(t) {
|
|
1393
1429
|
if (t === "string") {
|
|
1394
|
-
if (!this.dataType.equals(
|
|
1430
|
+
if (!this.dataType.equals(g.STRING))
|
|
1395
1431
|
throw new Error(
|
|
1396
1432
|
`cannot convert series of type ${this.dataType.toString()} to string`
|
|
1397
1433
|
);
|
|
@@ -1405,7 +1441,7 @@ const St = o.union([
|
|
|
1405
1441
|
return this;
|
|
1406
1442
|
}
|
|
1407
1443
|
if (t === "bigint") {
|
|
1408
|
-
if (!this.dataType.equals(
|
|
1444
|
+
if (!this.dataType.equals(g.INT64))
|
|
1409
1445
|
throw new Error(
|
|
1410
1446
|
`cannot convert series of type ${this.dataType.toString()} to bigint`
|
|
1411
1447
|
);
|
|
@@ -1434,7 +1470,7 @@ const St = o.union([
|
|
|
1434
1470
|
};
|
|
1435
1471
|
}
|
|
1436
1472
|
get alignmentBounds() {
|
|
1437
|
-
return
|
|
1473
|
+
return L(this.alignment, this.alignment + BigInt(this.length));
|
|
1438
1474
|
}
|
|
1439
1475
|
maybeGarbageCollectGLBuffer(t) {
|
|
1440
1476
|
this.gl.buffer != null && (t.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
|
|
@@ -1445,16 +1481,32 @@ const St = o.union([
|
|
|
1445
1481
|
}
|
|
1446
1482
|
[Symbol.iterator]() {
|
|
1447
1483
|
if (this.dataType.isVariable) {
|
|
1448
|
-
const t = new
|
|
1449
|
-
return this.dataType.equals(
|
|
1484
|
+
const t = new gt(this);
|
|
1485
|
+
return this.dataType.equals(g.JSON) ? new mt(t) : t;
|
|
1450
1486
|
}
|
|
1451
|
-
return new
|
|
1487
|
+
return new Ot(this);
|
|
1452
1488
|
}
|
|
1453
1489
|
slice(t, e) {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1490
|
+
return this.sliceSub(!1, t, e);
|
|
1491
|
+
}
|
|
1492
|
+
sub(t, e) {
|
|
1493
|
+
return this.sliceSub(!0, t, e);
|
|
1494
|
+
}
|
|
1495
|
+
subIterator(t, e) {
|
|
1496
|
+
return new G(this, t, e ?? this.length);
|
|
1497
|
+
}
|
|
1498
|
+
subAlignmentIterator(t, e) {
|
|
1499
|
+
return new G(
|
|
1500
|
+
this,
|
|
1501
|
+
Number(t - this.alignment),
|
|
1502
|
+
Number(e - this.alignment)
|
|
1503
|
+
);
|
|
1504
|
+
}
|
|
1505
|
+
subBytes(t, e) {
|
|
1506
|
+
if (t >= 0 && (e == null || e >= this.byteLength.valueOf())) return this;
|
|
1507
|
+
const n = this.data.subarray(t, e);
|
|
1508
|
+
return new I({
|
|
1509
|
+
data: n,
|
|
1458
1510
|
dataType: this.dataType,
|
|
1459
1511
|
timeRange: this._timeRange,
|
|
1460
1512
|
sampleOffset: this.sampleOffset,
|
|
@@ -1462,26 +1514,54 @@ const St = o.union([
|
|
|
1462
1514
|
alignment: this.alignment + BigInt(t)
|
|
1463
1515
|
});
|
|
1464
1516
|
}
|
|
1517
|
+
sliceSub(t, e, n) {
|
|
1518
|
+
if (e <= 0 && (n == null || n >= this.length)) return this;
|
|
1519
|
+
let i;
|
|
1520
|
+
return t ? i = this.data.subarray(e, n) : i = this.data.slice(e, n), new I({
|
|
1521
|
+
data: i,
|
|
1522
|
+
dataType: this.dataType,
|
|
1523
|
+
timeRange: this._timeRange,
|
|
1524
|
+
sampleOffset: this.sampleOffset,
|
|
1525
|
+
glBufferUsage: this.gl.bufferUsage,
|
|
1526
|
+
alignment: this.alignment + BigInt(e)
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1465
1529
|
reAlign(t) {
|
|
1466
|
-
return new
|
|
1530
|
+
return new I({
|
|
1467
1531
|
data: this.buffer,
|
|
1468
1532
|
dataType: this.dataType,
|
|
1469
|
-
timeRange:
|
|
1533
|
+
timeRange: E.ZERO,
|
|
1470
1534
|
sampleOffset: this.sampleOffset,
|
|
1471
1535
|
glBufferUsage: "static",
|
|
1472
1536
|
alignment: t
|
|
1473
1537
|
});
|
|
1474
1538
|
}
|
|
1475
1539
|
};
|
|
1476
|
-
s(
|
|
1477
|
-
timeRange:
|
|
1478
|
-
dataType:
|
|
1479
|
-
alignment:
|
|
1480
|
-
data: o.union([
|
|
1481
|
-
glBufferUsage:
|
|
1482
|
-
})), s(
|
|
1483
|
-
let
|
|
1484
|
-
class
|
|
1540
|
+
s(I, "crudeZ", o.object({
|
|
1541
|
+
timeRange: E.z.optional(),
|
|
1542
|
+
dataType: g.z,
|
|
1543
|
+
alignment: at.optional(),
|
|
1544
|
+
data: o.union([ht, dt, o.instanceof(ArrayBuffer)]),
|
|
1545
|
+
glBufferUsage: lt.optional().default("static").optional()
|
|
1546
|
+
})), s(I, "z", I.crudeZ.transform((t) => new I(t)));
|
|
1547
|
+
let V = I;
|
|
1548
|
+
class G {
|
|
1549
|
+
constructor(t, e, n) {
|
|
1550
|
+
s(this, "series");
|
|
1551
|
+
s(this, "end");
|
|
1552
|
+
s(this, "index");
|
|
1553
|
+
this.series = t;
|
|
1554
|
+
const i = L(0, t.length);
|
|
1555
|
+
this.end = k(i, n), this.index = k(i, e);
|
|
1556
|
+
}
|
|
1557
|
+
next() {
|
|
1558
|
+
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
1559
|
+
}
|
|
1560
|
+
[Symbol.iterator]() {
|
|
1561
|
+
return this;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
class gt {
|
|
1485
1565
|
constructor(t) {
|
|
1486
1566
|
s(this, "series");
|
|
1487
1567
|
s(this, "index");
|
|
@@ -1494,38 +1574,38 @@ class it {
|
|
|
1494
1574
|
}
|
|
1495
1575
|
next() {
|
|
1496
1576
|
const t = this.index, e = this.series.data;
|
|
1497
|
-
for (; this.index < e.length && e[this.index] !==
|
|
1498
|
-
const
|
|
1499
|
-
return t ===
|
|
1577
|
+
for (; this.index < e.length && e[this.index] !== Y; ) this.index++;
|
|
1578
|
+
const n = this.index;
|
|
1579
|
+
return t === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(t, n)) });
|
|
1500
1580
|
}
|
|
1501
1581
|
[Symbol.iterator]() {
|
|
1502
1582
|
return this;
|
|
1503
1583
|
}
|
|
1504
1584
|
}
|
|
1505
|
-
var
|
|
1506
|
-
class
|
|
1585
|
+
var J, W;
|
|
1586
|
+
class mt {
|
|
1507
1587
|
constructor(t) {
|
|
1508
1588
|
s(this, "wrapped");
|
|
1509
|
-
s(this,
|
|
1589
|
+
s(this, J, "JSONSeriesIterator");
|
|
1510
1590
|
this.wrapped = t;
|
|
1511
1591
|
}
|
|
1512
1592
|
next() {
|
|
1513
1593
|
const t = this.wrapped.next();
|
|
1514
1594
|
return t.done === !0 ? { done: !0, value: void 0 } : {
|
|
1515
1595
|
done: !1,
|
|
1516
|
-
value:
|
|
1596
|
+
value: $.decodeString(t.value)
|
|
1517
1597
|
};
|
|
1518
1598
|
}
|
|
1519
|
-
[(
|
|
1599
|
+
[(W = Symbol.iterator, J = Symbol.toStringTag, W)]() {
|
|
1520
1600
|
return this;
|
|
1521
1601
|
}
|
|
1522
1602
|
}
|
|
1523
|
-
var
|
|
1524
|
-
class
|
|
1603
|
+
var j, K;
|
|
1604
|
+
class Ot {
|
|
1525
1605
|
constructor(t) {
|
|
1526
1606
|
s(this, "series");
|
|
1527
1607
|
s(this, "index");
|
|
1528
|
-
s(this,
|
|
1608
|
+
s(this, j, "SeriesIterator");
|
|
1529
1609
|
this.series = t, this.index = 0;
|
|
1530
1610
|
}
|
|
1531
1611
|
next() {
|
|
@@ -1534,101 +1614,184 @@ class ut {
|
|
|
1534
1614
|
value: this.series.at(this.index++, !0)
|
|
1535
1615
|
};
|
|
1536
1616
|
}
|
|
1537
|
-
[(
|
|
1617
|
+
[(K = Symbol.iterator, j = Symbol.toStringTag, K)]() {
|
|
1538
1618
|
return this;
|
|
1539
1619
|
}
|
|
1540
1620
|
}
|
|
1541
|
-
const
|
|
1542
|
-
class
|
|
1621
|
+
const C = (l, t) => typeof l == "bigint" && typeof t == "bigint" || typeof l == "number" && typeof t == "number" ? l + t : t === 0 ? l : l === 0 ? t : Number(l) + Number(t);
|
|
1622
|
+
class Ct {
|
|
1543
1623
|
constructor(t) {
|
|
1544
1624
|
s(this, "series");
|
|
1545
1625
|
if (t.length !== 0) {
|
|
1546
1626
|
const e = t[0].dataType;
|
|
1547
|
-
for (let
|
|
1548
|
-
if (!t[
|
|
1627
|
+
for (let n = 1; n < t.length; n++)
|
|
1628
|
+
if (!t[n].dataType.equals(e))
|
|
1549
1629
|
throw new Error("[multi-series] - series must have the same data type");
|
|
1550
1630
|
}
|
|
1551
1631
|
this.series = t;
|
|
1552
1632
|
}
|
|
1553
1633
|
as(t) {
|
|
1554
|
-
if (!new
|
|
1634
|
+
if (!new g(t).equals(this.dataType))
|
|
1555
1635
|
throw new Error(
|
|
1556
1636
|
`cannot convert series of type ${this.dataType.toString()} to ${t.toString()}`
|
|
1557
1637
|
);
|
|
1558
1638
|
return this;
|
|
1559
1639
|
}
|
|
1560
1640
|
get dataType() {
|
|
1561
|
-
return this.series.length === 0 ?
|
|
1641
|
+
return this.series.length === 0 ? g.UNKNOWN : this.series[0].dataType;
|
|
1562
1642
|
}
|
|
1563
1643
|
get timeRange() {
|
|
1564
|
-
return this.series.length === 0 ?
|
|
1644
|
+
return this.series.length === 0 ? E.ZERO : new E(
|
|
1565
1645
|
this.series[0].timeRange.start,
|
|
1566
1646
|
this.series[this.series.length - 1].timeRange.end
|
|
1567
1647
|
);
|
|
1568
1648
|
}
|
|
1649
|
+
get alignment() {
|
|
1650
|
+
return this.series.length === 0 ? 0n : this.series[0].alignment;
|
|
1651
|
+
}
|
|
1652
|
+
get alignmentBounds() {
|
|
1653
|
+
return this.series.length === 0 ? L(0n, 0n) : L(
|
|
1654
|
+
this.series[0].alignmentBounds.lower,
|
|
1655
|
+
this.series[this.series.length - 1].alignmentBounds.upper
|
|
1656
|
+
);
|
|
1657
|
+
}
|
|
1569
1658
|
push(t) {
|
|
1570
1659
|
this.series.push(t);
|
|
1571
1660
|
}
|
|
1572
1661
|
get length() {
|
|
1573
1662
|
return this.series.reduce((t, e) => t + e.length, 0);
|
|
1574
1663
|
}
|
|
1664
|
+
atAlignment(t, e) {
|
|
1665
|
+
if (this.series.length === 0) {
|
|
1666
|
+
if (e) throw new Error(`[series] - no value at alignment ${t}`);
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
for (const n of this.series)
|
|
1670
|
+
if (D(n.alignmentBounds, t))
|
|
1671
|
+
return n.atAlignment(t, e);
|
|
1672
|
+
if (e) throw new Error(`[series] - no value at alignment ${t}`);
|
|
1673
|
+
}
|
|
1575
1674
|
at(t, e = !1) {
|
|
1576
1675
|
t < 0 && (t = this.length + t);
|
|
1577
|
-
for (const
|
|
1578
|
-
if (t <
|
|
1579
|
-
t -=
|
|
1676
|
+
for (const n of this.series) {
|
|
1677
|
+
if (t < n.length) return n.at(t, e);
|
|
1678
|
+
t -= n.length;
|
|
1580
1679
|
}
|
|
1581
1680
|
if (e) throw new Error(`[series] - no value at index ${t}`);
|
|
1582
1681
|
}
|
|
1682
|
+
subIterator(t, e) {
|
|
1683
|
+
return new F(this, t, e ?? this.length);
|
|
1684
|
+
}
|
|
1685
|
+
subAlignmentIterator(t, e) {
|
|
1686
|
+
if (t >= this.alignmentBounds.upper || e <= this.alignmentBounds.lower)
|
|
1687
|
+
return q;
|
|
1688
|
+
let n = 0;
|
|
1689
|
+
for (let c = 0; c < this.series.length; c++) {
|
|
1690
|
+
const h = this.series[c];
|
|
1691
|
+
if (t < h.alignment) break;
|
|
1692
|
+
if (t >= h.alignmentBounds.upper) n += h.length;
|
|
1693
|
+
else if (D(h.alignmentBounds, t)) {
|
|
1694
|
+
n += Number(t - h.alignment);
|
|
1695
|
+
break;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
let i = 0;
|
|
1699
|
+
for (let c = 0; c < this.series.length; c++) {
|
|
1700
|
+
const h = this.series[c];
|
|
1701
|
+
if (e < h.alignment) break;
|
|
1702
|
+
if (e >= h.alignmentBounds.upper) i += h.length;
|
|
1703
|
+
else if (D(h.alignmentBounds, e)) {
|
|
1704
|
+
i += Number(e - h.alignment);
|
|
1705
|
+
break;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
return new F(this, n, i);
|
|
1709
|
+
}
|
|
1710
|
+
subAlignmentSpanIterator(t, e) {
|
|
1711
|
+
if (t >= this.alignmentBounds.upper) return q;
|
|
1712
|
+
let n = 0;
|
|
1713
|
+
for (let i = 0; i < this.series.length; i++) {
|
|
1714
|
+
const c = this.series[i];
|
|
1715
|
+
if (t < c.alignment) break;
|
|
1716
|
+
if (t >= c.alignmentBounds.upper) n += c.length;
|
|
1717
|
+
else if (D(c.alignmentBounds, t)) {
|
|
1718
|
+
n += Number(t - c.alignment);
|
|
1719
|
+
break;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return new F(this, n, n + e);
|
|
1723
|
+
}
|
|
1583
1724
|
get byteLength() {
|
|
1584
|
-
return new
|
|
1725
|
+
return new x(this.series.reduce((t, e) => t + e.byteLength.valueOf(), 0));
|
|
1585
1726
|
}
|
|
1586
1727
|
get data() {
|
|
1587
1728
|
const t = new this.dataType.Array(this.length);
|
|
1588
1729
|
let e = 0;
|
|
1589
|
-
for (const
|
|
1590
|
-
t.set(
|
|
1730
|
+
for (const n of this.series)
|
|
1731
|
+
t.set(n.data, e), e += n.length;
|
|
1591
1732
|
return new this.dataType.Array(t);
|
|
1592
1733
|
}
|
|
1734
|
+
traverseAlignment(t, e) {
|
|
1735
|
+
const n = this.series.map((i) => i.alignmentBounds);
|
|
1736
|
+
return st(n, t, e);
|
|
1737
|
+
}
|
|
1738
|
+
distance(t, e) {
|
|
1739
|
+
const n = this.series.map((i) => i.alignmentBounds);
|
|
1740
|
+
return it(n, t, e);
|
|
1741
|
+
}
|
|
1593
1742
|
[Symbol.iterator]() {
|
|
1594
1743
|
return this.series.length === 0 ? {
|
|
1595
1744
|
next() {
|
|
1596
1745
|
return { done: !0, value: void 0 };
|
|
1597
1746
|
}
|
|
1598
|
-
} : new
|
|
1747
|
+
} : new yt(this.series);
|
|
1599
1748
|
}
|
|
1600
1749
|
}
|
|
1601
|
-
var
|
|
1602
|
-
class
|
|
1750
|
+
var z, H;
|
|
1751
|
+
class yt {
|
|
1603
1752
|
constructor(t) {
|
|
1604
1753
|
s(this, "series");
|
|
1605
1754
|
s(this, "seriesIndex");
|
|
1606
1755
|
s(this, "internal");
|
|
1607
|
-
s(this,
|
|
1756
|
+
s(this, z, "MultiSeriesIterator");
|
|
1608
1757
|
this.series = t, this.seriesIndex = 0, this.internal = t[0][Symbol.iterator]();
|
|
1609
1758
|
}
|
|
1610
1759
|
next() {
|
|
1611
1760
|
const t = this.internal.next();
|
|
1612
1761
|
return t.done === !1 ? t : this.seriesIndex === this.series.length - 1 ? { done: !0, value: void 0 } : (this.internal = this.series[++this.seriesIndex][Symbol.iterator](), this.next());
|
|
1613
1762
|
}
|
|
1614
|
-
[(
|
|
1763
|
+
[(H = Symbol.iterator, z = Symbol.toStringTag, H)]() {
|
|
1764
|
+
return this;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
class F {
|
|
1768
|
+
constructor(t, e, n) {
|
|
1769
|
+
s(this, "series");
|
|
1770
|
+
s(this, "index");
|
|
1771
|
+
s(this, "end");
|
|
1772
|
+
this.series = t, this.end = n, this.index = e;
|
|
1773
|
+
}
|
|
1774
|
+
next() {
|
|
1775
|
+
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
1776
|
+
}
|
|
1777
|
+
[Symbol.iterator]() {
|
|
1615
1778
|
return this;
|
|
1616
1779
|
}
|
|
1617
1780
|
}
|
|
1618
1781
|
export {
|
|
1619
1782
|
b as D,
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1783
|
+
Ct as M,
|
|
1784
|
+
P as R,
|
|
1785
|
+
V as S,
|
|
1623
1786
|
m as T,
|
|
1624
|
-
|
|
1787
|
+
C as a,
|
|
1625
1788
|
y as b,
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1789
|
+
E as c,
|
|
1790
|
+
g as d,
|
|
1791
|
+
x as e,
|
|
1792
|
+
_ as f,
|
|
1793
|
+
ct as g,
|
|
1794
|
+
Rt as h,
|
|
1795
|
+
ft as i,
|
|
1796
|
+
xt as t
|
|
1634
1797
|
};
|