@synnaxlabs/x 0.7.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.
Files changed (164) hide show
  1. package/.eslintrc.cjs +18 -0
  2. package/.turbo/turbo-build.log +16 -0
  3. package/.vscode/settings.json +3 -0
  4. package/LICENSE +4 -0
  5. package/README.md +44 -0
  6. package/dist/binary/encoder.d.ts +59 -0
  7. package/dist/binary/encoder.spec.d.ts +1 -0
  8. package/dist/binary/index.d.ts +1 -0
  9. package/dist/case.d.ts +5 -0
  10. package/dist/change/change.d.ts +32 -0
  11. package/dist/change/index.d.ts +1 -0
  12. package/dist/clamp.d.ts +1 -0
  13. package/dist/compare/compare.d.ts +39 -0
  14. package/dist/compare/index.d.ts +1 -0
  15. package/dist/debounce.d.ts +2 -0
  16. package/dist/deep/copy.d.ts +1 -0
  17. package/dist/deep/delete.d.ts +2 -0
  18. package/dist/deep/delete.spec.d.ts +1 -0
  19. package/dist/deep/equal.d.ts +8 -0
  20. package/dist/deep/equal.spec.d.ts +1 -0
  21. package/dist/deep/external.d.ts +7 -0
  22. package/dist/deep/index.d.ts +1 -0
  23. package/dist/deep/key.d.ts +30 -0
  24. package/dist/deep/memo.d.ts +1 -0
  25. package/dist/deep/merge.d.ts +2 -0
  26. package/dist/deep/merge.spec.d.ts +1 -0
  27. package/dist/deep/partial.d.ts +3 -0
  28. package/dist/destructor.d.ts +1 -0
  29. package/dist/identity.d.ts +1 -0
  30. package/dist/index.d.ts +25 -0
  31. package/dist/join.d.ts +1 -0
  32. package/dist/kv/index.d.ts +1 -0
  33. package/dist/kv/types.d.ts +32 -0
  34. package/dist/mock/MockGLBufferController.d.ts +20 -0
  35. package/dist/mock/index.d.ts +1 -0
  36. package/dist/observe/index.d.ts +1 -0
  37. package/dist/observe/observe.d.ts +11 -0
  38. package/dist/optional.d.ts +1 -0
  39. package/dist/primitive.d.ts +8 -0
  40. package/dist/record.d.ts +14 -0
  41. package/dist/renderable.d.ts +4 -0
  42. package/dist/runtime/detect.d.ts +9 -0
  43. package/dist/runtime/external.d.ts +2 -0
  44. package/dist/runtime/index.d.ts +1 -0
  45. package/dist/runtime/os.d.ts +9 -0
  46. package/dist/search.d.ts +15 -0
  47. package/dist/spatial/base.d.ts +102 -0
  48. package/dist/spatial/bounds.d.ts +31 -0
  49. package/dist/spatial/bounds.spec.d.ts +1 -0
  50. package/dist/spatial/box.d.ts +265 -0
  51. package/dist/spatial/box.spec.d.ts +1 -0
  52. package/dist/spatial/dimensions.d.ts +59 -0
  53. package/dist/spatial/dimensions.spec.d.ts +1 -0
  54. package/dist/spatial/direction.d.ts +10 -0
  55. package/dist/spatial/direction.spec.d.ts +1 -0
  56. package/dist/spatial/external.d.ts +8 -0
  57. package/dist/spatial/index.d.ts +1 -0
  58. package/dist/spatial/location.d.ts +52 -0
  59. package/dist/spatial/location.spec.d.ts +1 -0
  60. package/dist/spatial/position.d.ts +2 -0
  61. package/dist/spatial/scale.d.ts +241 -0
  62. package/dist/spatial/scale.spec.d.ts +1 -0
  63. package/dist/spatial/spatial.d.ts +1 -0
  64. package/dist/spatial/xy.d.ts +116 -0
  65. package/dist/spatial/xy.spec.d.ts +1 -0
  66. package/dist/telem/encode.d.ts +1 -0
  67. package/dist/telem/generate.d.ts +2 -0
  68. package/dist/telem/gl.d.ts +11 -0
  69. package/dist/telem/index.d.ts +3 -0
  70. package/dist/telem/series.d.ts +104 -0
  71. package/dist/telem/series.spec.d.ts +1 -0
  72. package/dist/telem/telem.d.ts +633 -0
  73. package/dist/telem/telem.spec.d.ts +1 -0
  74. package/dist/toArray.d.ts +1 -0
  75. package/dist/transform.d.ts +1 -0
  76. package/dist/unique.d.ts +1 -0
  77. package/dist/url/index.d.ts +1 -0
  78. package/dist/url/url.d.ts +46 -0
  79. package/dist/url/url.spec.d.ts +1 -0
  80. package/dist/worker/worker.d.ts +32 -0
  81. package/dist/worker/worker.spec.d.ts +1 -0
  82. package/dist/x.cjs.js +9046 -0
  83. package/dist/x.cjs.js.map +1 -0
  84. package/dist/x.es.js +9047 -0
  85. package/dist/x.es.js.map +1 -0
  86. package/package.json +42 -0
  87. package/src/binary/encoder.spec.ts +31 -0
  88. package/src/binary/encoder.ts +118 -0
  89. package/src/binary/index.ts +10 -0
  90. package/src/case.ts +31 -0
  91. package/src/change/change.ts +31 -0
  92. package/src/change/index.ts +10 -0
  93. package/src/clamp.ts +14 -0
  94. package/src/compare/compare.ts +116 -0
  95. package/src/compare/index.ts +10 -0
  96. package/src/debounce.ts +45 -0
  97. package/src/deep/copy.ts +13 -0
  98. package/src/deep/delete.spec.ts +36 -0
  99. package/src/deep/delete.ts +27 -0
  100. package/src/deep/equal.spec.ts +82 -0
  101. package/src/deep/equal.ts +65 -0
  102. package/src/deep/external.ts +15 -0
  103. package/src/deep/index.ts +10 -0
  104. package/src/deep/key.ts +46 -0
  105. package/src/deep/merge.spec.ts +63 -0
  106. package/src/deep/merge.ts +41 -0
  107. package/src/deep/partial.ts +14 -0
  108. package/src/destructor.ts +10 -0
  109. package/src/identity.ts +14 -0
  110. package/src/index.ts +34 -0
  111. package/src/join.ts +14 -0
  112. package/src/kv/index.ts +10 -0
  113. package/src/kv/types.ts +52 -0
  114. package/src/mock/MockGLBufferController.ts +70 -0
  115. package/src/mock/index.ts +10 -0
  116. package/src/observe/index.ts +10 -0
  117. package/src/observe/observe.ts +33 -0
  118. package/src/optional.ts +10 -0
  119. package/src/primitive.ts +46 -0
  120. package/src/record.ts +45 -0
  121. package/src/renderable.ts +20 -0
  122. package/src/runtime/detect.ts +34 -0
  123. package/src/runtime/external.ts +11 -0
  124. package/src/runtime/index.ts +10 -0
  125. package/src/runtime/os.ts +38 -0
  126. package/src/search.ts +40 -0
  127. package/src/spatial/base.ts +80 -0
  128. package/src/spatial/bounds.spec.ts +99 -0
  129. package/src/spatial/bounds.ts +80 -0
  130. package/src/spatial/box.spec.ts +137 -0
  131. package/src/spatial/box.ts +326 -0
  132. package/src/spatial/dimensions.spec.ts +47 -0
  133. package/src/spatial/dimensions.ts +64 -0
  134. package/src/spatial/direction.spec.ts +25 -0
  135. package/src/spatial/direction.ts +47 -0
  136. package/src/spatial/external.ts +17 -0
  137. package/src/spatial/index.ts +10 -0
  138. package/src/spatial/location.spec.ts +24 -0
  139. package/src/spatial/location.ts +124 -0
  140. package/src/spatial/position.ts +26 -0
  141. package/src/spatial/scale.spec.ts +74 -0
  142. package/src/spatial/scale.ts +351 -0
  143. package/src/spatial/spatial.ts +17 -0
  144. package/src/spatial/xy.spec.ts +68 -0
  145. package/src/spatial/xy.ts +164 -0
  146. package/src/telem/encode.ts +22 -0
  147. package/src/telem/generate.ts +19 -0
  148. package/src/telem/gl.ts +22 -0
  149. package/src/telem/index.ts +12 -0
  150. package/src/telem/series.spec.ts +289 -0
  151. package/src/telem/series.ts +449 -0
  152. package/src/telem/telem.spec.ts +302 -0
  153. package/src/telem/telem.ts +1237 -0
  154. package/src/toArray.ts +11 -0
  155. package/src/transform.ts +10 -0
  156. package/src/unique.ts +10 -0
  157. package/src/url/index.ts +10 -0
  158. package/src/url/url.spec.ts +47 -0
  159. package/src/url/url.ts +113 -0
  160. package/src/worker/worker.spec.ts +41 -0
  161. package/src/worker/worker.ts +86 -0
  162. package/tsconfig.json +7 -0
  163. package/tsconfig.vite.json +4 -0
  164. package/vite.config.ts +23 -0
@@ -0,0 +1,633 @@
1
+ import { z } from "zod";
2
+ import { type Stringer } from '../primitive';
3
+ export type TZInfo = "UTC" | "local";
4
+ export type TimeStampStringFormat = "ISO" | "ISODate" | "ISOTime" | "time" | "preciseTime" | "date" | "preciseDate" | "shortDate" | "dateTime";
5
+ export type DateComponents = [number?, number?, number?];
6
+ /**
7
+ * Represents a UTC timestamp. Synnax uses a nanosecond precision int64 timestamp.
8
+ *
9
+ * DISCLAIMER: JavaScript stores all numbers as 64-bit floating point numbers, so we expect a
10
+ * expect a precision drop from nanoseconds to quarter microseconds when communicating
11
+ * with the server. If this is a problem, please file an issue with the Synnax team.
12
+ * Caveat emptor.
13
+ *
14
+ * @param value - The timestamp value to parse. This can be any of the following:
15
+ *
16
+ * 1. A number representing the number of milliseconds since the Unix epoch.
17
+ * 2. A javascript Date object.
18
+ * 3. An array of numbers satisfying the DateComponents type, where the first element is the
19
+ * year, the second is the month, and the third is the day. To increaase resolution
20
+ * when using this method, use the add method. It's important to note that this initializes
21
+ * a timestamp at midnight UTC, regardless of the timezone specified.
22
+ * 4. An ISO compliant date or date time string. The time zone component is ignored.
23
+ *
24
+ * @param tzInfo - The timezone to use when parsing the timestamp. This can be either "UTC" or
25
+ * "local". This parameter is ignored if the value is a Date object or a DateComponents array.
26
+ *
27
+ * @example ts = new TimeStamp(1 * TimeSpan.HOUR) // 1 hour after the Unix epoch
28
+ * @example ts = new TimeStamp([2021, 1, 1]) // 1/1/2021 at midnight UTC
29
+ * @example ts = new TimeStamp([2021, 1, 1]).add(1 * TimeSpan.HOUR) // 1/1/2021 at 1am UTC
30
+ * @example ts = new TimeStamp("2021-01-01T12:30:00Z") // 1/1/2021 at 12:30pm UTC
31
+ */
32
+ export declare class TimeStamp extends Number implements Stringer {
33
+ constructor(value?: CrudeTimeStamp, tzInfo?: TZInfo);
34
+ private static parseDate;
35
+ private static parseTimeString;
36
+ private static parseDateTimeString;
37
+ fString(format?: TimeStampStringFormat, tzInfo?: TZInfo): string;
38
+ private toISOString;
39
+ private timeString;
40
+ private dateString;
41
+ static get utcOffset(): TimeSpan;
42
+ /**
43
+ * @returns a TimeSpan representing the amount time elapsed since
44
+ * the other timestamp.
45
+ * @param other - The other timestamp.
46
+ */
47
+ static since(other: TimeStamp): TimeSpan;
48
+ /** @returns A JavaScript Date object representing the TimeStamp. */
49
+ date(): Date;
50
+ /**
51
+ * Checks if the TimeStamp is equal to another TimeStamp.
52
+ *
53
+ * @param other - The other TimeStamp to compare to.
54
+ * @returns True if the TimeStamps are equal, false otherwise.
55
+ */
56
+ equals(other: CrudeTimeStamp): boolean;
57
+ /**
58
+ * Creates a TimeSpan representing the duration between the two timestamps.
59
+ *
60
+ * @param other - The other TimeStamp to compare to.
61
+ * @returns A TimeSpan representing the duration between the two timestamps.
62
+ * The span is guaranteed to be positive.
63
+ */
64
+ span(other: CrudeTimeStamp): TimeSpan;
65
+ /**
66
+ * Creates a TimeRange spanning the given TimeStamp.
67
+ *
68
+ * @param other - The other TimeStamp to compare to.
69
+ * @returns A TimeRange spanning the given TimeStamp that is guaranteed to be
70
+ * valid, regardless of the TimeStamp order.
71
+ */
72
+ range(other: CrudeTimeStamp): TimeRange;
73
+ /**
74
+ * Creates a TimeRange starting at the TimeStamp and spanning the given
75
+ * TimeSpan.
76
+ *
77
+ * @param other - The TimeSpan to span.
78
+ * @returns A TimeRange starting at the TimeStamp and spanning the given
79
+ * TimeSpan. The TimeRange is guaranteed to be valid.
80
+ */
81
+ spanRange(other: CrudeTimeSpan): TimeRange;
82
+ /**
83
+ * Checks if the TimeStamp represents the unix epoch.
84
+ *
85
+ * @returns True if the TimeStamp represents the unix epoch, false otherwise.
86
+ */
87
+ get isZero(): boolean;
88
+ /**
89
+ * Checks if the TimeStamp is after the given TimeStamp.
90
+ *
91
+ * @param other - The other TimeStamp to compare to.
92
+ * @returns True if the TimeStamp is after the given TimeStamp, false
93
+ * otherwise.
94
+ */
95
+ after(other: CrudeTimeStamp): boolean;
96
+ /**
97
+ * Checks if the TimeStamp is after or equal to the given TimeStamp.
98
+ *
99
+ * @param other - The other TimeStamp to compare to.
100
+ * @returns True if the TimeStamp is after or equal to the given TimeStamp,
101
+ * false otherwise.
102
+ */
103
+ afterEq(other: CrudeTimeStamp): boolean;
104
+ /**
105
+ * Checks if the TimeStamp is before the given TimeStamp.
106
+ *
107
+ * @param other - The other TimeStamp to compare to.
108
+ * @returns True if the TimeStamp is before the given TimeStamp, false
109
+ * otherwise.
110
+ */
111
+ before(other: CrudeTimeStamp): boolean;
112
+ /**
113
+ * Checks if TimeStamp is before or equal to the current timestamp.
114
+ *
115
+ * @param other - The other TimeStamp to compare to.
116
+ * @returns True if TimeStamp is before or equal to the current timestamp,
117
+ * false otherwise.
118
+ */
119
+ beforeEq(other: CrudeTimeStamp): boolean;
120
+ /**
121
+ * Adds a TimeSpan to the TimeStamp.
122
+ *
123
+ * @param span - The TimeSpan to add.
124
+ * @returns A new TimeStamp representing the sum of the TimeStamp and
125
+ * TimeSpan.
126
+ */
127
+ add(span: CrudeTimeSpan): TimeStamp;
128
+ /**
129
+ * Subtracts a TimeSpan from the TimeStamp.
130
+ *
131
+ * @param span - The TimeSpan to subtract.
132
+ * @returns A new TimeStamp representing the difference of the TimeStamp and
133
+ * TimeSpan.
134
+ */
135
+ sub(span: CrudeTimeSpan): TimeStamp;
136
+ /**
137
+ * @returns The number of milliseconds since the unix epoch.
138
+ */
139
+ milliseconds(): number;
140
+ toString(): string;
141
+ /**
142
+ * @returns A new TimeStamp that is the remainder of the TimeStamp divided by the
143
+ * given span. This is useful in cases where you want only part of a TimeStamp's value
144
+ * i.e. the hours, minutes, seconds, milliseconds, microseconds, and nanoseconds but
145
+ * not the days, years, etc.
146
+ *
147
+ * @param divisor - The TimeSpan to divide by. Must be an even TimeSpan or TimeStamp. Even
148
+ * means it must be a day, hour, minute, second, millisecond, or microsecond, etc.
149
+ *
150
+ * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
151
+ */
152
+ remainder(divisor: TimeSpan | TimeStamp): TimeStamp;
153
+ /** @returns true if the day portion TimeStamp is today, false otherwise. */
154
+ get isToday(): boolean;
155
+ truncate(span: TimeSpan | TimeStamp): TimeStamp;
156
+ /**
157
+ * @returns A new TimeStamp representing the current time in UTC. It's important to
158
+ * note that this TimeStamp is only accurate to the millisecond level (that's the best
159
+ * JavaScript can do).
160
+ */
161
+ static now(): TimeStamp;
162
+ /** @returns a new TimeStamp n nanoseconds after the unix epoch */
163
+ static nanoseconds(value: number): TimeStamp;
164
+ static readonly NANOSECOND: TimeStamp;
165
+ /** @returns a new TimeStamp n microseconds after the unix epoch */
166
+ static microseconds(value: number): TimeStamp;
167
+ /** One microsecond after the unix epoch */
168
+ static readonly MICROSECOND: TimeStamp;
169
+ /** @returns a new TimeStamp n milliseconds after the unix epoch */
170
+ static milliseconds(value: number): TimeStamp;
171
+ /** One millisecond after the unix epoch */
172
+ static readonly MILLISECOND: TimeStamp;
173
+ /** @returns a new TimeStamp n seconds after the unix epoch */
174
+ static seconds(value: number): TimeStamp;
175
+ /** One second after the unix epoch */
176
+ static readonly SECOND: TimeStamp;
177
+ /** @returns a new TimeStamp n minutes after the unix epoch */
178
+ static minutes(value: number): TimeStamp;
179
+ /** One minute after the unix epoch */
180
+ static readonly MINUTE: TimeStamp;
181
+ /** @returns a new TimeStamp n hours after the unix epoch */
182
+ static hours(value: number): TimeStamp;
183
+ /** One hour after the unix epoch */
184
+ static readonly HOUR: TimeStamp;
185
+ /** @returns a new TimeStamp n days after the unix epoch */
186
+ static days(value: number): TimeStamp;
187
+ /** One day after the unix epoch */
188
+ static readonly DAY: TimeStamp;
189
+ /** The maximum possible value for a timestamp */
190
+ static readonly MAX: TimeStamp;
191
+ /** The minimum possible value for a timestamp */
192
+ static readonly MIN: TimeStamp;
193
+ /** The unix epoch */
194
+ static readonly ZERO: TimeStamp;
195
+ /** A zod schema for validating timestamps */
196
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
197
+ }
198
+ /** TimeSpan represents a nanosecond precision duration. */
199
+ export declare class TimeSpan extends Number implements Stringer {
200
+ constructor(value: CrudeTimeSpan);
201
+ remainder(divisor: TimeSpan): TimeSpan;
202
+ truncate(span: TimeSpan): TimeSpan;
203
+ toString(): string;
204
+ /** @returns the decimal number of days in the timespan */
205
+ get days(): number;
206
+ /** @returns the decimal number of hours in the timespan */
207
+ get hours(): number;
208
+ /** @returns the decimal number of minutes in the timespan */
209
+ get minutes(): number;
210
+ /** @returns The number of seconds in the TimeSpan. */
211
+ get seconds(): number;
212
+ /** @returns The number of milliseconds in the TimeSpan. */
213
+ get milliseconds(): number;
214
+ get microseconds(): number;
215
+ get nanoseconds(): number;
216
+ /**
217
+ * Checks if the TimeSpan represents a zero duration.
218
+ *
219
+ * @returns True if the TimeSpan represents a zero duration, false otherwise.
220
+ */
221
+ get isZero(): boolean;
222
+ /**
223
+ * Checks if the TimeSpan is equal to another TimeSpan.
224
+ *
225
+ * @returns True if the TimeSpans are equal, false otherwise.
226
+ */
227
+ equals(other: CrudeTimeSpan): boolean;
228
+ /**
229
+ * Adds a TimeSpan to the TimeSpan.
230
+ *
231
+ * @returns A new TimeSpan representing the sum of the two TimeSpans.
232
+ */
233
+ add(other: CrudeTimeSpan): TimeSpan;
234
+ /**
235
+ * Creates a TimeSpan representing the duration between the two timestamps.
236
+ *
237
+ * @param other
238
+ */
239
+ sub(other: CrudeTimeSpan): TimeSpan;
240
+ /**
241
+ * Creates a TimeSpan representing the given number of nanoseconds.
242
+ *
243
+ * @param value - The number of nanoseconds.
244
+ * @returns A TimeSpan representing the given number of nanoseconds.
245
+ */
246
+ static nanoseconds(value?: number): TimeSpan;
247
+ /** A nanosecond. */
248
+ static readonly NANOSECOND: TimeSpan;
249
+ /**
250
+ * Creates a TimeSpan representing the given number of microseconds.
251
+ *
252
+ * @param value - The number of microseconds.
253
+ * @returns A TimeSpan representing the given number of microseconds.
254
+ */
255
+ static microseconds(value?: number): TimeSpan;
256
+ /** A microsecond. */
257
+ static readonly MICROSECOND: TimeSpan;
258
+ /**
259
+ * Creates a TimeSpan representing the given number of milliseconds.
260
+ *
261
+ * @param value - The number of milliseconds.
262
+ * @returns A TimeSpan representing the given number of milliseconds.
263
+ */
264
+ static milliseconds(value?: number): TimeSpan;
265
+ /** A millisecond. */
266
+ static readonly MILLISECOND: TimeSpan;
267
+ /**
268
+ * Creates a TimeSpan representing the given number of seconds.
269
+ *
270
+ * @param value - The number of seconds.
271
+ * @returns A TimeSpan representing the given number of seconds.
272
+ */
273
+ static seconds(value?: number): TimeSpan;
274
+ /** A second. */
275
+ static readonly SECOND: TimeSpan;
276
+ /**
277
+ * Creates a TimeSpan representing the given number of minutes.
278
+ *
279
+ * @param value - The number of minutes.
280
+ * @returns A TimeSpan representing the given number of minutes.
281
+ */
282
+ static minutes(value: number): TimeSpan;
283
+ /** A minute. */
284
+ static readonly MINUTE: TimeSpan;
285
+ /**
286
+ * Creates a TimeSpan representing the given number of hours.
287
+ *
288
+ * @param value - The number of hours.
289
+ * @returns A TimeSpan representing the given number of hours.
290
+ */
291
+ static hours(value: number): TimeSpan;
292
+ /** Represents an hour. */
293
+ static readonly HOUR: TimeSpan;
294
+ /**
295
+ * Creates a TimeSpan representing the given number of days.
296
+ *
297
+ * @param value - The number of days.
298
+ * @returns A TimeSpan representing the given number of days.
299
+ */
300
+ static days(value: number): TimeSpan;
301
+ /** Represents a day. */
302
+ static readonly DAY: TimeSpan;
303
+ /** The maximum possible value for a TimeSpan. */
304
+ static readonly MAX: TimeSpan;
305
+ /** The minimum possible value for a TimeSpan. */
306
+ static readonly MIN: TimeSpan;
307
+ /** The zero value for a TimeSpan. */
308
+ static readonly ZERO: TimeSpan;
309
+ /** A zod schema for validating and transforming timespans */
310
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeSpan, Number>, z.ZodEffects<z.ZodNumber, TimeSpan, number>, z.ZodType<TimeSpan, z.ZodTypeDef, TimeSpan>]>;
311
+ }
312
+ /** Rate represents a data rate in Hz. */
313
+ export declare class Rate extends Number implements Stringer {
314
+ constructor(value: CrudeRate);
315
+ /** @returns a pretty string representation of the rate in the format "X Hz". */
316
+ toString(): string;
317
+ /** @returns The number of seconds in the Rate. */
318
+ equals(other: CrudeRate): boolean;
319
+ /**
320
+ * Calculates the period of the Rate as a TimeSpan.
321
+ *
322
+ * @returns A TimeSpan representing the period of the Rate.
323
+ */
324
+ get period(): TimeSpan;
325
+ /**
326
+ * Calculates the number of samples in the given TimeSpan at this rate.
327
+ *
328
+ * @param duration - The duration to calculate the sample count from.
329
+ * @returns The number of samples in the given TimeSpan at this rate.
330
+ */
331
+ sampleCount(duration: CrudeTimeSpan): number;
332
+ /**
333
+ * Calculates the number of bytes in the given TimeSpan at this rate.
334
+ *
335
+ * @param span - The duration to calculate the byte count from.
336
+ * @param density - The density of the data in bytes per sample.
337
+ * @returns The number of bytes in the given TimeSpan at this rate.
338
+ */
339
+ byteCount(span: CrudeTimeSpan, density: CrudeDensity): number;
340
+ /**
341
+ * Calculates a TimeSpan given the number of samples at this rate.
342
+ *
343
+ * @param sampleCount - The number of samples in the span.
344
+ * @returns A TimeSpan that corresponds to the given number of samples.
345
+ */
346
+ span(sampleCount: number): TimeSpan;
347
+ /**
348
+ * Calculates a TimeSpan given the number of bytes at this rate.
349
+ *
350
+ * @param size - The number of bytes in the span.
351
+ * @param density - The density of the data in bytes per sample.
352
+ * @returns A TimeSpan that corresponds to the given number of bytes.
353
+ */
354
+ byteSpan(size: Size, density: CrudeDensity): TimeSpan;
355
+ /**
356
+ * Creates a Rate representing the given number of Hz.
357
+ *
358
+ * @param value - The number of Hz.
359
+ * @returns A Rate representing the given number of Hz.
360
+ */
361
+ static hz(value: number): Rate;
362
+ /**
363
+ * Creates a Rate representing the given number of kHz.
364
+ *
365
+ * @param value - The number of kHz.
366
+ * @returns A Rate representing the given number of kHz.
367
+ */
368
+ static khz(value: number): Rate;
369
+ /** A zod schema for validating and transforming rates */
370
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodNumber, Rate, number>, z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, Rate, Number>, z.ZodType<Rate, z.ZodTypeDef, Rate>]>;
371
+ }
372
+ /** Density represents the number of bytes in a value. */
373
+ export declare class Density extends Number implements Stringer {
374
+ /**
375
+ * Creates a Density representing the given number of bytes per value.
376
+ *
377
+ * @class
378
+ * @param value - The number of bytes per value.
379
+ * @returns A Density representing the given number of bytes per value.
380
+ */
381
+ constructor(value: CrudeDensity);
382
+ length(size: Size): number;
383
+ size(sampleCount: number): Size;
384
+ /** Unknown/Invalid Density. */
385
+ static readonly UNKNOWN: Density;
386
+ /** 128 bits per value. */
387
+ static readonly BIT128: Density;
388
+ /** 64 bits per value. */
389
+ static readonly BIT64: Density;
390
+ /** 32 bits per value. */
391
+ static readonly BIT32: Density;
392
+ /** 16 bits per value. */
393
+ static readonly BIT16: Density;
394
+ /** 8 bits per value. */
395
+ static readonly BIT8: Density;
396
+ /** A zod schema for validating and transforming densities */
397
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodNumber, Density, number>, z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, Density, Number>, z.ZodType<Density, z.ZodTypeDef, Density>]>;
398
+ }
399
+ /**
400
+ * TimeRange is a range of time marked by a start and end timestamp. A TimeRange
401
+ * is start inclusive and end exclusive.
402
+ *
403
+ * @property start - A TimeStamp representing the start of the range.
404
+ * @property end - A Timestamp representing the end of the range.
405
+ */
406
+ export declare class TimeRange implements Stringer {
407
+ /**
408
+ * The starting TimeStamp of the TimeRange.
409
+ *
410
+ * Note that this value is not guaranteed to be before or equal to the ending value.
411
+ * To ensure that this is the case, call TimeRange.make_valid().
412
+ *
413
+ * In most cases, operations should treat start as inclusive.
414
+ */
415
+ start: TimeStamp;
416
+ /**
417
+ * The starting TimeStamp of the TimeRange.
418
+ *
419
+ * Note that this value is not guaranteed to be before or equal to the ending value.
420
+ * To ensure that this is the case, call TimeRange.make_valid().
421
+ *
422
+ * In most cases, operations should treat end as exclusive.
423
+ */
424
+ end: TimeStamp;
425
+ /**
426
+ * Creates a TimeRange from the given start and end TimeStamps.
427
+ *
428
+ * @param start - A TimeStamp representing the start of the range.
429
+ * @param end - A TimeStamp representing the end of the range.
430
+ */
431
+ constructor(start: CrudeTimeStamp, end: CrudeTimeStamp);
432
+ /** @returns The TimeSpan occupied by the TimeRange. */
433
+ get span(): TimeSpan;
434
+ /**
435
+ * Checks if the timestamp is valid i.e. the start is before the end.
436
+ *
437
+ * @returns True if the TimeRange is valid.
438
+ */
439
+ get isValid(): boolean;
440
+ /**
441
+ * Makes sure the TimeRange is valid i.e. the start is before the end.
442
+ *
443
+ * @returns A TimeRange that is valid.
444
+ */
445
+ makeValid(): TimeRange;
446
+ /**
447
+ * Checks if the TimeRange has a zero span.
448
+ *
449
+ * @returns True if the TimeRange has a zero span.
450
+ */
451
+ get isZero(): boolean;
452
+ /**
453
+ * Creates a new TimeRange with the start and end swapped.
454
+ *
455
+ * @returns A TimeRange with the start and end swapped.
456
+ */
457
+ swap(): TimeRange;
458
+ /**
459
+ * Checks if the TimeRange is equal to the given TimeRange.
460
+ *
461
+ * @param other - The TimeRange to compare to.
462
+ * @returns True if the TimeRange is equal to the given TimeRange.
463
+ */
464
+ equals(other: TimeRange): boolean;
465
+ toString(): string;
466
+ toPrettyString(): string;
467
+ overlapsWith(other: TimeRange): boolean;
468
+ contains(other: TimeRange): boolean;
469
+ contains(ts: CrudeTimeStamp): boolean;
470
+ /** The maximum possible time range. */
471
+ static readonly MAX: TimeRange;
472
+ /** The minimum possible time range. */
473
+ static readonly MIN: TimeRange;
474
+ /** A zero time range. */
475
+ static readonly ZERO: TimeRange;
476
+ /** A zod schema for validating and transforming time ranges */
477
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
478
+ start: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
479
+ end: z.ZodUnion<[z.ZodEffects<z.ZodType<Number, z.ZodTypeDef, Number>, TimeStamp, Number>, z.ZodEffects<z.ZodNumber, TimeStamp, number>, z.ZodType<TimeStamp, z.ZodTypeDef, TimeStamp>]>;
480
+ }, "strip", z.ZodTypeAny, {
481
+ start: TimeStamp;
482
+ end: TimeStamp;
483
+ }, {
484
+ start: (number | Number | TimeStamp) & (number | Number | TimeStamp | undefined);
485
+ end: (number | Number | TimeStamp) & (number | Number | TimeStamp | undefined);
486
+ }>, TimeRange, {
487
+ start: (number | Number | TimeStamp) & (number | Number | TimeStamp | undefined);
488
+ end: (number | Number | TimeStamp) & (number | Number | TimeStamp | undefined);
489
+ }>, z.ZodType<TimeRange, z.ZodTypeDef, TimeRange>]>;
490
+ }
491
+ /** DataType is a string that represents a data type. */
492
+ export declare class DataType extends String implements Stringer {
493
+ constructor(value: CrudeDataType);
494
+ /**
495
+ * @returns the TypedArray constructor for the DataType.
496
+ */
497
+ get Array(): NativeTypedArrayConstructor;
498
+ equals(other: DataType): boolean;
499
+ /** @returns a string representation of the DataType. */
500
+ toString(): string;
501
+ get density(): Density;
502
+ /**
503
+ * Checks whether the given TypedArray is of the same type as the DataType.
504
+ *
505
+ * @param array - The TypedArray to check.
506
+ * @returns True if the TypedArray is of the same type as the DataType.
507
+ */
508
+ checkArray(array: NativeTypedArray): boolean;
509
+ toJSON(): string;
510
+ get usesBigInt(): boolean;
511
+ /** Represents an Unknown/Invalid DataType. */
512
+ static readonly UNKNOWN: DataType;
513
+ /** Represents a 64-bit floating point value. */
514
+ static readonly FLOAT64: DataType;
515
+ /** Represents a 32-bit floating point value. */
516
+ static readonly FLOAT32: DataType;
517
+ /** Represents a 64-bit signed integer value. */
518
+ static readonly INT64: DataType;
519
+ /** Represents a 32-bit signed integer value. */
520
+ static readonly INT32: DataType;
521
+ /** Represents a 16-bit signed integer value. */
522
+ static readonly INT16: DataType;
523
+ /** Represents a 8-bit signed integer value. */
524
+ static readonly INT8: DataType;
525
+ /** Represents a 64-bit unsigned integer value. */
526
+ static readonly UINT64: DataType;
527
+ /** Represents a 32-bit unsigned integer value. */
528
+ static readonly UINT32: DataType;
529
+ /** Represents a 16-bit unsigned integer value. */
530
+ static readonly UINT16: DataType;
531
+ /** Represents a 8-bit unsigned integer value. */
532
+ static readonly UINT8: DataType;
533
+ /** Represents a 64-bit unix epoch. */
534
+ static readonly TIMESTAMP: DataType;
535
+ /** Represents a UUID data type */
536
+ static readonly UUID: DataType;
537
+ /** Represents a string data type. Strings have an unknown density, and are separate
538
+ * by a newline character. */
539
+ static readonly STRING: DataType;
540
+ /** Represents a JSON data type. JSON has an unknown density, and is separated by a
541
+ * newline character. */
542
+ static readonly JSON: DataType;
543
+ static readonly ARRAY_CONSTRUCTORS: Map<string, NativeTypedArrayConstructor>;
544
+ static readonly ARRAY_CONSTRUCTOR_DATA_TYPES: Map<string, DataType>;
545
+ static readonly DENSITIES: Map<string, Density>;
546
+ static readonly BIG_INT_TYPES: DataType[];
547
+ /** A zod schema for a DataType. */
548
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodString, DataType, string>, z.ZodType<DataType, z.ZodTypeDef, DataType>]>;
549
+ }
550
+ /**
551
+ * The Size of an elementy in bytes.
552
+ */
553
+ export declare class Size extends Number implements Stringer {
554
+ constructor(value: CrudeSize);
555
+ /** @returns true if the Size is larger than the other size. */
556
+ largerThan(other: CrudeSize): boolean;
557
+ /** @returns true if the Size is smaller than the other sisze. */
558
+ smallerThan(other: CrudeSize): boolean;
559
+ add(other: CrudeSize): Size;
560
+ sub(other: CrudeSize): Size;
561
+ /**
562
+ * Creates a Size from the given number of bytes.
563
+ *
564
+ * @param value - The number of bytes.
565
+ * @returns A Size representing the given number of bytes.
566
+ */
567
+ static bytes(value?: CrudeSize): Size;
568
+ /** A single byte */
569
+ static readonly BYTE: Size;
570
+ /**
571
+ * Creates a Size from the given number if kilobytes.
572
+ *
573
+ * @param value - The number of kilobytes.
574
+ * @returns A Size representing the given number of kilobytes.
575
+ */
576
+ static kilobytes(value?: CrudeSize): Size;
577
+ /** A kilobyte */
578
+ static readonly KILOBYTE: Size;
579
+ /**
580
+ * Creates a Size from the given number of megabytes.
581
+ *
582
+ * @param value - The number of megabytes.
583
+ * @returns A Size representing the given number of megabytes.
584
+ */
585
+ static megabytes(value?: CrudeSize): Size;
586
+ /** A megabyte */
587
+ static readonly MEGABYTE: Size;
588
+ /**
589
+ * Creates a Size from the given number of gigabytes.
590
+ *
591
+ * @param value - The number of gigabytes.
592
+ * @returns A Size representing the given number of gigabytes.
593
+ */
594
+ static gigabytes(value?: CrudeSize): Size;
595
+ /** A gigabyte */
596
+ static readonly GIGABYTE: Size;
597
+ /**
598
+ * Creates a Size from the given number of terabytes.
599
+ *
600
+ * @param value - The number of terabytes.
601
+ * @returns A Size representing the given number of terabytes.
602
+ */
603
+ static terabytes(value: CrudeSize): Size;
604
+ /** A terabyte. */
605
+ static readonly TERABYTE: Size;
606
+ /** The zero value for Size */
607
+ static readonly ZERO: Size;
608
+ /** A zod schema for a Size. */
609
+ static readonly z: z.ZodUnion<[z.ZodEffects<z.ZodNumber, Size, number>, z.ZodType<Size, z.ZodTypeDef, Size>]>;
610
+ isZero(): boolean;
611
+ }
612
+ export type CrudeTimeStamp = TimeStamp | TimeSpan | number | Date | string | DateComponents | Number;
613
+ export type TimeStampT = number;
614
+ export type CrudeTimeSpan = TimeSpan | TimeStamp | number | Number;
615
+ export type TimeSpanT = number;
616
+ export type CrudeRate = Rate | number | Number;
617
+ export type RateT = number;
618
+ export type CrudeDensity = Density | number | Number;
619
+ export type DensityT = number;
620
+ export type CrudeDataType = DataType | string | NativeTypedArray;
621
+ export type DataTypeT = string;
622
+ export type CrudeSize = Size | number | Number;
623
+ export type SizeT = number;
624
+ export interface CrudeTimeRange {
625
+ start: TimeStampT;
626
+ end: TimeStampT;
627
+ }
628
+ export declare const nativeTypedArray: z.ZodUnion<[z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>, z.ZodType<Uint16Array, z.ZodTypeDef, Uint16Array>, z.ZodType<Uint32Array, z.ZodTypeDef, Uint32Array>, z.ZodType<BigUint64Array, z.ZodTypeDef, BigUint64Array>, z.ZodType<Float32Array, z.ZodTypeDef, Float32Array>, z.ZodType<Float64Array, z.ZodTypeDef, Float64Array>, z.ZodType<Int8Array, z.ZodTypeDef, Int8Array>, z.ZodType<Int16Array, z.ZodTypeDef, Int16Array>, z.ZodType<Int32Array, z.ZodTypeDef, Int32Array>, z.ZodType<BigInt64Array, z.ZodTypeDef, BigInt64Array>]>;
629
+ export type NativeTypedArray = z.infer<typeof nativeTypedArray>;
630
+ type NativeTypedArrayConstructor = Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | BigUint64ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor | Int32ArrayConstructor | BigInt64ArrayConstructor;
631
+ type TelemValue = number | bigint;
632
+ export declare const convertDataType: (source: DataType, target: DataType, value: TelemValue, offset?: number | bigint) => TelemValue;
633
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const toArray: <T>(value: T | T[]) => T[];
@@ -0,0 +1 @@
1
+ export type ArrayTransform<E = unknown, R = E> = (data: E[]) => R[];
@@ -0,0 +1 @@
1
+ export declare const unique: <V>(values: V[] | readonly V[]) => V[];
@@ -0,0 +1 @@
1
+ export * from "./url";