@synnaxlabs/x 0.42.1 → 0.43.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 (296) hide show
  1. package/.turbo/turbo-build.log +93 -105
  2. package/.vscode/settings.json +4 -6
  3. package/README.md +1 -7
  4. package/dist/array.cjs +1 -0
  5. package/dist/array.js +7 -0
  6. package/dist/base-B5lQIJKc.js +38 -0
  7. package/dist/base-CTq-lhpU.cjs +1 -0
  8. package/dist/binary.cjs +1 -1
  9. package/dist/binary.js +1 -1
  10. package/dist/bounds.cjs +1 -1
  11. package/dist/bounds.js +2 -2
  12. package/dist/box.cjs +1 -1
  13. package/dist/box.js +1 -1
  14. package/dist/caseconv.cjs +1 -1
  15. package/dist/caseconv.js +2 -2
  16. package/dist/change.cjs +1 -1
  17. package/dist/change.js +10 -2
  18. package/dist/compare.cjs +1 -1
  19. package/dist/compare.js +1 -1
  20. package/dist/deep.cjs +1 -1
  21. package/dist/deep.js +92 -79
  22. package/dist/dimensions.cjs +1 -1
  23. package/dist/dimensions.js +41 -2
  24. package/dist/direction.cjs +1 -1
  25. package/dist/direction.js +1 -1
  26. package/dist/index-4GlOgZuh.js +99 -0
  27. package/dist/{direction-C-b6XTeU.cjs → index-B58dnYRu.cjs} +1 -1
  28. package/dist/index-BMGaoK93.cjs +1 -0
  29. package/dist/index-BTet04Hd.cjs +6 -0
  30. package/dist/{scale-DfJe9755.js → index-BUa-NXAX.js} +46 -46
  31. package/dist/{xy-D_LqxaGt.js → index-C-qYOegc.js} +62 -62
  32. package/dist/index-C07SBJhr.js +128 -0
  33. package/dist/{bounds-Bn5_l4Z3.js → index-C9EdKeu1.js} +77 -76
  34. package/dist/index-CM8ZDZ6s.cjs +1 -0
  35. package/dist/index-CV2JaHfw.cjs +1 -0
  36. package/dist/index-CeBvOwG8.cjs +3 -0
  37. package/dist/index-ClrGyGDp.js +205 -0
  38. package/dist/index-CqQXXeCI.cjs +1 -0
  39. package/dist/{location-C3aeu046.js → index-D6V-8SKw.js} +26 -26
  40. package/dist/index-DBGAIs_7.js +2492 -0
  41. package/dist/index-DEdq2tza.cjs +1 -0
  42. package/dist/index-DKMnHBGR.cjs +1 -0
  43. package/dist/index-Dql5FMcH.js +47 -0
  44. package/dist/{direction-BL0PhD1k.js → index-DxU1zwsd.js} +1 -1
  45. package/dist/index-WwMnwoLy.cjs +1 -0
  46. package/dist/index.cjs +5 -3
  47. package/dist/index.js +5372 -649
  48. package/dist/kv.cjs +1 -1
  49. package/dist/kv.js +45 -2
  50. package/dist/location.cjs +1 -1
  51. package/dist/location.js +1 -1
  52. package/dist/position.cjs +1 -1
  53. package/dist/position.js +83 -2
  54. package/dist/record.cjs +1 -1
  55. package/dist/record.js +8 -10
  56. package/dist/runtime.cjs +1 -1
  57. package/dist/runtime.js +27 -2
  58. package/dist/scale.cjs +1 -1
  59. package/dist/scale.js +1 -1
  60. package/dist/schemas-55Usj0Fg.js +3998 -0
  61. package/dist/schemas-DbXuI2Qr.cjs +27 -0
  62. package/dist/spatial.cjs +1 -1
  63. package/dist/spatial.js +25 -18
  64. package/dist/src/array/index.d.ts +2 -0
  65. package/dist/src/array/index.d.ts.map +1 -0
  66. package/dist/src/array/toArray.d.ts +19 -0
  67. package/dist/src/array/toArray.d.ts.map +1 -0
  68. package/dist/src/array/toArray.spec.d.ts +2 -0
  69. package/dist/src/array/toArray.spec.d.ts.map +1 -0
  70. package/dist/src/binary/codec.d.ts +8 -16
  71. package/dist/src/binary/codec.d.ts.map +1 -1
  72. package/dist/src/breaker/breaker.d.ts +6 -6
  73. package/dist/src/breaker/breaker.d.ts.map +1 -1
  74. package/dist/src/caseconv/caseconv.d.ts +1 -1
  75. package/dist/src/caseconv/caseconv.d.ts.map +1 -1
  76. package/dist/src/change/change.d.ts +3 -3
  77. package/dist/src/change/change.d.ts.map +1 -1
  78. package/dist/src/color/color.d.ts +63 -28
  79. package/dist/src/color/color.d.ts.map +1 -1
  80. package/dist/src/color/external.d.ts +0 -1
  81. package/dist/src/color/external.d.ts.map +1 -1
  82. package/dist/src/color/gradient.d.ts +9 -5
  83. package/dist/src/color/gradient.d.ts.map +1 -1
  84. package/dist/src/color/palette.d.ts +14 -6
  85. package/dist/src/color/palette.d.ts.map +1 -1
  86. package/dist/src/compare/compare.d.ts +4 -4
  87. package/dist/src/compare/compare.d.ts.map +1 -1
  88. package/dist/src/control/control.d.ts +32 -32
  89. package/dist/src/control/control.d.ts.map +1 -1
  90. package/dist/src/debounce/debounce.d.ts +1 -1
  91. package/dist/src/debounce/debounce.d.ts.map +1 -1
  92. package/dist/src/deep/delete.d.ts +1 -1
  93. package/dist/src/deep/delete.d.ts.map +1 -1
  94. package/dist/src/deep/difference.d.ts.map +1 -1
  95. package/dist/src/deep/equal.d.ts +4 -4
  96. package/dist/src/deep/equal.d.ts.map +1 -1
  97. package/dist/src/deep/merge.d.ts +1 -1
  98. package/dist/src/deep/merge.d.ts.map +1 -1
  99. package/dist/src/errors/errors.d.ts +62 -36
  100. package/dist/src/errors/errors.d.ts.map +1 -1
  101. package/dist/src/index.d.ts +4 -1
  102. package/dist/src/index.d.ts.map +1 -1
  103. package/dist/src/instance/index.d.ts +2 -0
  104. package/dist/src/instance/index.d.ts.map +1 -0
  105. package/dist/src/instance/matcher.d.ts +79 -0
  106. package/dist/src/instance/matcher.d.ts.map +1 -0
  107. package/dist/src/instance/matcher.spec.d.ts +2 -0
  108. package/dist/src/instance/matcher.spec.d.ts.map +1 -0
  109. package/dist/src/jsonrpc/jsonrpc.d.ts +40 -9
  110. package/dist/src/jsonrpc/jsonrpc.d.ts.map +1 -1
  111. package/dist/src/kv/types.d.ts +2 -2
  112. package/dist/src/kv/types.d.ts.map +1 -1
  113. package/dist/src/migrate/migrate.d.ts +5 -5
  114. package/dist/src/migrate/migrate.d.ts.map +1 -1
  115. package/dist/src/notation/notation.d.ts +1 -1
  116. package/dist/src/notation/notation.d.ts.map +1 -1
  117. package/dist/src/primitive/index.d.ts +2 -0
  118. package/dist/src/primitive/index.d.ts.map +1 -0
  119. package/dist/src/primitive/primitive.d.ts +39 -0
  120. package/dist/src/primitive/primitive.d.ts.map +1 -0
  121. package/dist/src/primitive/primitive.spec.d.ts +2 -0
  122. package/dist/src/primitive/primitive.spec.d.ts.map +1 -0
  123. package/dist/src/record.d.ts +2 -2
  124. package/dist/src/record.d.ts.map +1 -1
  125. package/dist/src/renderable.d.ts +1 -1
  126. package/dist/src/renderable.d.ts.map +1 -1
  127. package/dist/src/replace.d.ts.map +1 -1
  128. package/dist/src/runtime/detect.d.ts.map +1 -1
  129. package/dist/src/runtime/os.d.ts +1 -1
  130. package/dist/src/runtime/os.d.ts.map +1 -1
  131. package/dist/src/spatial/base.d.ts +10 -10
  132. package/dist/src/spatial/base.d.ts.map +1 -1
  133. package/dist/src/spatial/bounds/bounds.d.ts +82 -16
  134. package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
  135. package/dist/src/spatial/box/box.d.ts +7 -7
  136. package/dist/src/spatial/box/box.d.ts.map +1 -1
  137. package/dist/src/spatial/dimensions/dimensions.d.ts +5 -5
  138. package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -1
  139. package/dist/src/spatial/direction/direction.d.ts +1 -1
  140. package/dist/src/spatial/location/location.d.ts +4 -4
  141. package/dist/src/spatial/location/location.d.ts.map +1 -1
  142. package/dist/src/spatial/scale/scale.d.ts +11 -11
  143. package/dist/src/spatial/scale/scale.d.ts.map +1 -1
  144. package/dist/src/spatial/xy/xy.d.ts +5 -5
  145. package/dist/src/spatial/xy/xy.d.ts.map +1 -1
  146. package/dist/src/status/index.d.ts +2 -0
  147. package/dist/src/status/index.d.ts.map +1 -0
  148. package/dist/src/status/types.d.ts +11 -0
  149. package/dist/src/status/types.d.ts.map +1 -0
  150. package/dist/src/sync/index.d.ts.map +1 -1
  151. package/dist/src/sync/mutex.d.ts +0 -1
  152. package/dist/src/sync/mutex.d.ts.map +1 -1
  153. package/dist/src/telem/gl.d.ts +1 -1
  154. package/dist/src/telem/gl.d.ts.map +1 -1
  155. package/dist/src/telem/series.d.ts +468 -62
  156. package/dist/src/telem/series.d.ts.map +1 -1
  157. package/dist/src/telem/telem.d.ts +243 -53
  158. package/dist/src/telem/telem.d.ts.map +1 -1
  159. package/dist/src/uuid/index.d.ts +2 -0
  160. package/dist/src/uuid/index.d.ts.map +1 -0
  161. package/dist/src/uuid/uuid.d.ts +35 -0
  162. package/dist/src/uuid/uuid.d.ts.map +1 -0
  163. package/dist/src/uuid/uuid.spec.d.ts +2 -0
  164. package/dist/src/uuid/uuid.spec.d.ts.map +1 -0
  165. package/dist/src/zod/external.d.ts +1 -1
  166. package/dist/src/zod/external.d.ts.map +1 -1
  167. package/dist/src/zod/nullToUndefined.d.ts +3 -0
  168. package/dist/src/zod/nullToUndefined.d.ts.map +1 -0
  169. package/dist/src/zod/nullToUndefined.spec.d.ts +2 -0
  170. package/dist/src/zod/nullToUndefined.spec.d.ts.map +1 -0
  171. package/dist/src/zod/util.d.ts +2 -2
  172. package/dist/src/zod/util.d.ts.map +1 -1
  173. package/dist/telem.cjs +1 -1
  174. package/dist/telem.js +1 -1
  175. package/dist/xy.cjs +1 -1
  176. package/dist/xy.js +1 -1
  177. package/dist/zod.cjs +1 -1
  178. package/dist/zod.js +19 -2
  179. package/eslint.config.js +1 -1
  180. package/package.json +16 -14
  181. package/src/{toArray.ts → array/index.ts} +1 -5
  182. package/src/array/toArray.spec.ts +56 -0
  183. package/src/array/toArray.ts +28 -0
  184. package/src/binary/codec.spec.ts +201 -278
  185. package/src/binary/codec.ts +20 -76
  186. package/src/breaker/breaker.ts +3 -3
  187. package/src/caseconv/caseconv.ts +6 -4
  188. package/src/change/change.ts +2 -2
  189. package/src/color/color.spec.ts +121 -2
  190. package/src/color/color.ts +90 -54
  191. package/src/color/external.ts +0 -1
  192. package/src/color/gradient.ts +20 -28
  193. package/src/color/palette.ts +1 -1
  194. package/src/compare/compare.ts +5 -5
  195. package/src/control/control.ts +22 -19
  196. package/src/debounce/debounce.ts +1 -1
  197. package/src/deep/delete.ts +5 -4
  198. package/src/deep/difference.ts +6 -2
  199. package/src/deep/equal.spec.ts +1 -1
  200. package/src/deep/equal.ts +5 -5
  201. package/src/deep/merge.spec.ts +13 -1
  202. package/src/deep/merge.ts +16 -7
  203. package/src/deep/path.ts +1 -1
  204. package/src/errors/errors.ts +65 -44
  205. package/src/index.ts +4 -1
  206. package/src/instance/index.ts +10 -0
  207. package/src/instance/matcher.spec.ts +78 -0
  208. package/src/instance/matcher.ts +98 -0
  209. package/src/jsonrpc/jsonrpc.spec.ts +2 -1
  210. package/src/jsonrpc/jsonrpc.ts +36 -7
  211. package/src/kv/types.ts +1 -1
  212. package/src/migrate/migrate.spec.ts +1 -1
  213. package/src/migrate/migrate.ts +7 -7
  214. package/src/notation/notation.ts +1 -1
  215. package/src/primitive/index.ts +10 -0
  216. package/src/primitive/primitive.spec.ts +126 -0
  217. package/src/primitive/primitive.ts +82 -0
  218. package/src/record.ts +3 -5
  219. package/src/renderable.ts +1 -1
  220. package/src/replace.ts +9 -0
  221. package/src/runtime/detect.ts +0 -2
  222. package/src/runtime/os.ts +1 -1
  223. package/src/spatial/base.ts +1 -1
  224. package/src/spatial/bounds/bounds.spec.ts +20 -0
  225. package/src/spatial/bounds/bounds.ts +101 -18
  226. package/src/spatial/box/box.ts +1 -1
  227. package/src/spatial/dimensions/dimensions.ts +3 -3
  228. package/src/spatial/location/location.ts +1 -1
  229. package/src/spatial/scale/scale.ts +1 -1
  230. package/src/spatial/xy/xy.ts +1 -1
  231. package/src/status/index.ts +10 -0
  232. package/src/status/types.ts +22 -0
  233. package/src/sync/index.ts +9 -0
  234. package/src/sync/mutex.ts +9 -4
  235. package/src/telem/gl.ts +1 -1
  236. package/src/telem/series.spec.ts +735 -68
  237. package/src/telem/series.ts +536 -195
  238. package/src/telem/telem.spec.ts +60 -7
  239. package/src/telem/telem.ts +287 -95
  240. package/src/uuid/index.ts +10 -0
  241. package/src/uuid/uuid.spec.ts +82 -0
  242. package/src/uuid/uuid.ts +48 -0
  243. package/src/zod/external.ts +1 -1
  244. package/src/zod/nullToUndefined.spec.ts +31 -0
  245. package/src/zod/nullToUndefined.ts +23 -0
  246. package/src/zod/util.spec.ts +1 -1
  247. package/src/zod/util.ts +6 -6
  248. package/tsconfig.json +1 -1
  249. package/tsconfig.tsbuildinfo +1 -1
  250. package/vite.config.ts +1 -1
  251. package/dist/base-BAM2mqCy.cjs +0 -1
  252. package/dist/base-DFq0vvGn.js +0 -38
  253. package/dist/bounds-BQo7rvs9.cjs +0 -1
  254. package/dist/box-0YrQibkB.cjs +0 -1
  255. package/dist/box-Cc8IzcNo.js +0 -205
  256. package/dist/change-C-YELKx6.cjs +0 -1
  257. package/dist/change-DLl6DccR.js +0 -12
  258. package/dist/dimensions-CRgergMS.js +0 -43
  259. package/dist/dimensions-D2QGoNXO.cjs +0 -1
  260. package/dist/external-BPgtxa8d.js +0 -29
  261. package/dist/external-C-dNgNQw.cjs +0 -1
  262. package/dist/external-C8TFju8Q.js +0 -29
  263. package/dist/external-DWQITF5_.cjs +0 -1
  264. package/dist/external-DqPrWKvU.js +0 -47
  265. package/dist/external-uXk0Avrg.cjs +0 -1
  266. package/dist/index-BywOGO8U.js +0 -1074
  267. package/dist/index-CYYjI7Uf.cjs +0 -1
  268. package/dist/index-C_6NXBlg.cjs +0 -3
  269. package/dist/index-Dd8DLyMx.cjs +0 -1
  270. package/dist/index-DizUWH6z.js +0 -47
  271. package/dist/index-QGplUHuy.js +0 -98
  272. package/dist/location-BGl5Ddds.cjs +0 -1
  273. package/dist/position-Cai5-wi1.cjs +0 -1
  274. package/dist/position-DIglP1l2.js +0 -85
  275. package/dist/scale-BtZINJ-A.cjs +0 -1
  276. package/dist/series-B9JERcqi.js +0 -1977
  277. package/dist/series-DqJ6f97G.cjs +0 -11
  278. package/dist/spatial-BSWPzMkK.js +0 -11
  279. package/dist/spatial-DGpZ2sO3.cjs +0 -1
  280. package/dist/src/color/transformColorsToHex.d.ts +0 -6
  281. package/dist/src/color/transformColorsToHex.d.ts.map +0 -1
  282. package/dist/src/primitive.d.ts +0 -9
  283. package/dist/src/primitive.d.ts.map +0 -1
  284. package/dist/src/toArray.d.ts +0 -3
  285. package/dist/src/toArray.d.ts.map +0 -1
  286. package/dist/src/zod/integer.d.ts +0 -10
  287. package/dist/src/zod/integer.d.ts.map +0 -1
  288. package/dist/src/zod/integer.spec.d.ts +0 -2
  289. package/dist/src/zod/integer.spec.d.ts.map +0 -1
  290. package/dist/toArray.cjs +0 -1
  291. package/dist/toArray.js +0 -5
  292. package/dist/xy-B7065J2S.cjs +0 -1
  293. package/src/color/transformColorsToHex.ts +0 -30
  294. package/src/primitive.ts +0 -46
  295. package/src/zod/integer.spec.ts +0 -148
  296. package/src/zod/integer.ts +0 -38
@@ -7,14 +7,16 @@
7
7
  // License, use of this software will be governed by the Apache License, Version 2.0,
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
- import { z } from "zod";
10
+ import { z } from "zod/v4";
11
11
 
12
12
  import { math } from "@/math";
13
- import { type Stringer } from "@/primitive";
13
+ import { primitive } from "@/primitive";
14
14
  import { type bounds } from "@/spatial";
15
15
 
16
+ /** Time zone specification when working with time stamps. */
16
17
  export type TZInfo = "UTC" | "local";
17
18
 
19
+ /** Different string formats for time stamps. */
18
20
  export type TimeStampStringFormat =
19
21
  | "ISO"
20
22
  | "ISODate"
@@ -26,6 +28,13 @@ export type TimeStampStringFormat =
26
28
  | "shortDate"
27
29
  | "dateTime";
28
30
 
31
+ /**
32
+ * A triple of numbers representing a date.
33
+ *
34
+ * @param year - The year.
35
+ * @param month - The month.
36
+ * @param day - The day.
37
+ */
29
38
  export type DateComponents = [number?, number?, number?];
30
39
 
31
40
  const remainder = <T extends TimeStamp | TimeSpan>(
@@ -52,7 +61,7 @@ const remainder = <T extends TimeStamp | TimeSpan>(
52
61
  };
53
62
 
54
63
  /**
55
- * Represents a UTC timestamp. Synnax uses a nanosecond precision int64 timestamp.
64
+ UTC timestamp. Synnax uses a nanosecond precision int64 timestamp.
56
65
  *
57
66
  * @param value - The timestamp value to parse. This can be any of the following:
58
67
  *
@@ -72,19 +81,17 @@ const remainder = <T extends TimeStamp | TimeSpan>(
72
81
  * @example ts = new TimeStamp([2021, 1, 1]).add(1 * TimeSpan.HOUR) // 1/1/2021 at 1am UTC
73
82
  * @example ts = new TimeStamp("2021-01-01T12:30:00Z") // 1/1/2021 at 12:30pm UTC
74
83
  */
75
- export class TimeStamp implements Stringer {
76
- /** The underlying value for the time stamp */
77
- private readonly value: bigint;
78
- /** Makes sure JSON encodes the value and not the class. */
79
- readonly encodeValue = true;
80
-
84
+ export class TimeStamp
85
+ extends primitive.ValueExtension<bigint>
86
+ implements primitive.Stringer
87
+ {
81
88
  constructor(value?: CrudeTimeStamp, tzInfo: TZInfo = "UTC") {
82
- if (value == null) this.value = TimeStamp.now().valueOf();
89
+ if (value == null) super(TimeStamp.now().valueOf());
83
90
  else if (value instanceof Date)
84
- this.value = BigInt(value.getTime()) * TimeStamp.MILLISECOND.valueOf();
91
+ super(BigInt(value.getTime()) * TimeStamp.MILLISECOND.valueOf());
85
92
  else if (typeof value === "string")
86
- this.value = TimeStamp.parseDateTimeString(value, tzInfo).valueOf();
87
- else if (Array.isArray(value)) this.value = TimeStamp.parseDate(value);
93
+ super(TimeStamp.parseDateTimeString(value, tzInfo).valueOf());
94
+ else if (Array.isArray(value)) super(TimeStamp.parseDate(value));
88
95
  else {
89
96
  let offset: bigint = BigInt(0);
90
97
  if (value instanceof Number) value = value.valueOf();
@@ -96,7 +103,7 @@ export class TimeStamp implements Stringer {
96
103
  if (value === Infinity) value = TimeStamp.MAX;
97
104
  else value = TimeStamp.MIN;
98
105
  }
99
- this.value = BigInt(value.valueOf()) + offset;
106
+ super(BigInt(value.valueOf()) + offset);
100
107
  }
101
108
  }
102
109
 
@@ -108,6 +115,10 @@ export class TimeStamp implements Stringer {
108
115
  .valueOf();
109
116
  }
110
117
 
118
+ /**
119
+ * @returns the primitive value of the TimeStamp. Overrides standard JS valueOf()
120
+ * method.
121
+ */
111
122
  valueOf(): bigint {
112
123
  return this.value;
113
124
  }
@@ -138,6 +149,13 @@ export class TimeStamp implements Stringer {
138
149
  ).valueOf();
139
150
  }
140
151
 
152
+ /**
153
+ * Formats the TimeStamp as a string in the specified format.
154
+ *
155
+ * @param format - The format to use for the string representation.
156
+ * @param tzInfo - The timezone to use when creating the string representation.
157
+ * @returns A string representation of the TimeStamp in the specified format.
158
+ */
141
159
  fString(format: TimeStampStringFormat = "ISO", tzInfo: TZInfo = "UTC"): string {
142
160
  switch (format) {
143
161
  case "ISODate":
@@ -176,6 +194,7 @@ export class TimeStamp implements Stringer {
176
194
  return `${month} ${day}`;
177
195
  }
178
196
 
197
+ /** @returns The UTC offset for the time zone of the machine. */
179
198
  static get utcOffset(): TimeSpan {
180
199
  return new TimeSpan(
181
200
  BigInt(new Date().getTimezoneOffset()) * TimeStamp.MINUTE.valueOf(),
@@ -352,7 +371,7 @@ export class TimeStamp implements Stringer {
352
371
  return Number(this.valueOf()) / Number(TimeStamp.MILLISECOND.valueOf());
353
372
  }
354
373
 
355
- /** @returns the floating point number of microseconds since the unix epoch */
374
+ /** @returns the floating point number of microseconds since the unix epoch. */
356
375
  get microseconds(): number {
357
376
  return Number(this.valueOf()) / Number(TimeStamp.MICROSECOND.valueOf());
358
377
  }
@@ -368,7 +387,7 @@ export class TimeStamp implements Stringer {
368
387
 
369
388
  /** @returns the integer year that the timestamp corresponds to. */
370
389
  get year(): number {
371
- return this.date().getFullYear();
390
+ return this.date().getUTCFullYear();
372
391
  }
373
392
 
374
393
  /**
@@ -377,7 +396,7 @@ export class TimeStamp implements Stringer {
377
396
  */
378
397
  setYear(year: number): TimeStamp {
379
398
  const d = this.date();
380
- d.setFullYear(year);
399
+ d.setUTCFullYear(year);
381
400
  return new TimeStamp(d);
382
401
  }
383
402
 
@@ -430,7 +449,7 @@ export class TimeStamp implements Stringer {
430
449
 
431
450
  /** @returns the integer minute that the timestamp corresponds to within its hour. */
432
451
  get minute(): number {
433
- return this.date().getMinutes();
452
+ return this.date().getUTCMinutes();
434
453
  }
435
454
 
436
455
  /**
@@ -448,7 +467,7 @@ export class TimeStamp implements Stringer {
448
467
  * minute.
449
468
  */
450
469
  get second(): number {
451
- return this.date().getSeconds();
470
+ return this.date().getUTCSeconds();
452
471
  }
453
472
 
454
473
  /**
@@ -466,7 +485,7 @@ export class TimeStamp implements Stringer {
466
485
  * its second.
467
486
  */
468
487
  get millisecond(): number {
469
- return this.date().getMilliseconds();
488
+ return this.date().getUTCMilliseconds();
470
489
  }
471
490
 
472
491
  /**
@@ -475,7 +494,7 @@ export class TimeStamp implements Stringer {
475
494
  */
476
495
  setMillisecond(millisecond: number): TimeStamp {
477
496
  const d = this.date();
478
- d.setMilliseconds(millisecond);
497
+ d.setUTCMilliseconds(millisecond);
479
498
  return new TimeStamp(d);
480
499
  }
481
500
 
@@ -504,6 +523,12 @@ export class TimeStamp implements Stringer {
504
523
  return this.truncate(TimeSpan.DAY).equals(TimeStamp.now().truncate(TimeSpan.DAY));
505
524
  }
506
525
 
526
+ /**
527
+ * Truncates the TimeStamp to the nearest multiple of the given span.
528
+ *
529
+ * @param span - The TimeSpan to truncate to.
530
+ * @returns A new TimeStamp that is truncated to the nearest multiple of the given span.
531
+ */
507
532
  truncate(span: TimeSpan | TimeStamp): TimeStamp {
508
533
  return this.sub(this.remainder(span));
509
534
  }
@@ -517,7 +542,12 @@ export class TimeStamp implements Stringer {
517
542
  return new TimeStamp(new Date());
518
543
  }
519
544
 
520
- /** @returns the maximum value of all the timestamps. */
545
+ /**
546
+ * Finds the maximum timestamp among the provided timestamps.
547
+ *
548
+ * @param timestamps - The timestamps to compare.
549
+ * @returns The maximum (latest) timestamp from the input.
550
+ */
521
551
  static max(...timestamps: CrudeTimeStamp[]): TimeStamp {
522
552
  let max = TimeStamp.MIN;
523
553
  for (const ts of timestamps) {
@@ -527,7 +557,12 @@ export class TimeStamp implements Stringer {
527
557
  return max;
528
558
  }
529
559
 
530
- /** @returns the minimum value of all the timestamps. */
560
+ /**
561
+ * Finds the minimum timestamp among the provided timestamps.
562
+ *
563
+ * @param timestamps - The timestamps to compare.
564
+ * @returns The minimum (earliest) timestamp from the input.
565
+ */
531
566
  static min(...timestamps: CrudeTimeStamp[]): TimeStamp {
532
567
  let min = TimeStamp.MAX;
533
568
  for (const ts of timestamps) {
@@ -537,7 +572,12 @@ export class TimeStamp implements Stringer {
537
572
  return min;
538
573
  }
539
574
 
540
- /** @returns a new TimeStamp n nanoseconds after the unix epoch */
575
+ /**
576
+ * Creates a TimeStamp representing the given number of nanoseconds.
577
+ *
578
+ * @param value - The number of nanoseconds.
579
+ * @returns A TimeStamp representing the given number of nanoseconds.
580
+ */
541
581
  static nanoseconds(value: number, tzInfo: TZInfo = "UTC"): TimeStamp {
542
582
  return new TimeStamp(value, tzInfo);
543
583
  }
@@ -613,15 +653,21 @@ export class TimeStamp implements Stringer {
613
653
  }
614
654
 
615
655
  /** TimeSpan represents a nanosecond precision duration. */
616
- export class TimeSpan implements Stringer {
617
- private readonly value: bigint;
618
- readonly encodeValue = true;
619
-
656
+ export class TimeSpan
657
+ extends primitive.ValueExtension<bigint>
658
+ implements primitive.Stringer
659
+ {
620
660
  constructor(value: CrudeTimeSpan) {
621
661
  if (typeof value === "number") value = Math.trunc(value.valueOf());
622
- this.value = BigInt(value.valueOf());
662
+ super(BigInt(value.valueOf()));
623
663
  }
624
664
 
665
+ /**
666
+ * Creates a TimeSpan representing the given number of seconds.
667
+ *
668
+ * @param span - The number of seconds.
669
+ * @returns A TimeSpan representing the given number of seconds.
670
+ */
625
671
  static fromSeconds(span: CrudeTimeSpan): TimeSpan {
626
672
  if (span instanceof TimeSpan) return span;
627
673
  if (span instanceof Rate) return span.period;
@@ -630,6 +676,12 @@ export class TimeSpan implements Stringer {
630
676
  return new TimeSpan(span);
631
677
  }
632
678
 
679
+ /**
680
+ * Creates a TimeSpan representing the given number of milliseconds.
681
+ *
682
+ * @param span - The number of milliseconds.
683
+ * @returns A TimeSpan representing the given number of milliseconds.
684
+ */
633
685
  static fromMilliseconds(span: CrudeTimeSpan): TimeSpan {
634
686
  if (span instanceof TimeSpan) return span;
635
687
  if (span instanceof Rate) return span.period;
@@ -638,40 +690,81 @@ export class TimeSpan implements Stringer {
638
690
  return new TimeSpan(span);
639
691
  }
640
692
 
641
- encode(): string {
642
- return this.value.toString();
643
- }
644
-
693
+ /**
694
+ * @returns the primitive value of the TimeSpan. Overrides standard JS valueOf()
695
+ * method.
696
+ */
645
697
  valueOf(): bigint {
646
698
  return this.value;
647
699
  }
648
700
 
701
+ /**
702
+ * Checks if the TimeSpan is less than another TimeSpan.
703
+ *
704
+ * @param other - The TimeSpan to compare against.
705
+ * @returns True if the TimeSpan is less than the other TimeSpan, false otherwise.
706
+ */
649
707
  lessThan(other: CrudeTimeSpan): boolean {
650
708
  return this.valueOf() < new TimeSpan(other).valueOf();
651
709
  }
652
710
 
711
+ /**
712
+ * Checks if the TimeSpan is greater than another TimeSpan.
713
+ *
714
+ * @param other - The TimeSpan to compare against.
715
+ * @returns True if the TimeSpan is greater than the other TimeSpan, false otherwise.
716
+ */
653
717
  greaterThan(other: CrudeTimeSpan): boolean {
654
718
  return this.valueOf() > new TimeSpan(other).valueOf();
655
719
  }
656
720
 
721
+ /**
722
+ * Checks if the TimeSpan is less than or equal to another TimeSpan.
723
+ *
724
+ * @param other - The TimeSpan to compare against.
725
+ * @returns True if the TimeSpan is less than or equal to the other TimeSpan, false otherwise.
726
+ */
657
727
  lessThanOrEqual(other: CrudeTimeSpan): boolean {
658
728
  return this.valueOf() <= new TimeSpan(other).valueOf();
659
729
  }
660
730
 
731
+ /**
732
+ * Checks if the TimeSpan is greater than or equal to another TimeSpan.
733
+ *
734
+ * @param other - The TimeSpan to compare against.
735
+ * @returns True if the TimeSpan is greater than or equal to the other TimeSpan, false otherwise.
736
+ */
661
737
  greaterThanOrEqual(other: CrudeTimeSpan): boolean {
662
738
  return this.valueOf() >= new TimeSpan(other).valueOf();
663
739
  }
664
740
 
741
+ /**
742
+ * Calculates the remainder of the TimeSpan when divided by another TimeSpan.
743
+ *
744
+ * @param divisor - The TimeSpan to divide by.
745
+ * @returns A new TimeSpan representing the remainder.
746
+ */
665
747
  remainder(divisor: TimeSpan): TimeSpan {
666
748
  return remainder(this, divisor);
667
749
  }
668
750
 
751
+ /**
752
+ * Truncates the TimeSpan to the nearest multiple of the given span.
753
+ *
754
+ * @param span - The TimeSpan to truncate to.
755
+ * @returns A new TimeSpan that is truncated to the nearest multiple of the given span.
756
+ */
669
757
  truncate(span: TimeSpan): TimeSpan {
670
758
  return new TimeSpan(
671
759
  BigInt(Math.trunc(Number(this.valueOf() / span.valueOf()))) * span.valueOf(),
672
760
  );
673
761
  }
674
762
 
763
+ /**
764
+ * Returns a string representation of the TimeSpan.
765
+ *
766
+ * @returns A string representation of the TimeSpan.
767
+ */
675
768
  toString(): string {
676
769
  const totalDays = this.truncate(TimeSpan.DAY);
677
770
  const totalHours = this.truncate(TimeSpan.HOUR);
@@ -699,21 +792,27 @@ export class TimeSpan implements Stringer {
699
792
  return str.trim();
700
793
  }
701
794
 
795
+ /**
796
+ * Multiplies the TimeSpan by a scalar value.
797
+ *
798
+ * @param value - The scalar value to multiply by.
799
+ * @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
800
+ */
702
801
  mult(value: number): TimeSpan {
703
802
  return new TimeSpan(this.valueOf() * BigInt(value));
704
803
  }
705
804
 
706
- /** @returns the decimal number of days in the timespan */
805
+ /** @returns the decimal number of days in the TimeSpan. */
707
806
  get days(): number {
708
807
  return Number(this.valueOf()) / Number(TimeSpan.DAY.valueOf());
709
808
  }
710
809
 
711
- /** @returns the decimal number of hours in the timespan */
810
+ /** @returns the decimal number of hours in the TimeSpan. */
712
811
  get hours(): number {
713
812
  return Number(this.valueOf()) / Number(TimeSpan.HOUR.valueOf());
714
813
  }
715
814
 
716
- /** @returns the decimal number of minutes in the timespan */
815
+ /** @returns the decimal number of minutes in the TimeSpan. */
717
816
  get minutes(): number {
718
817
  return Number(this.valueOf()) / Number(TimeSpan.MINUTE.valueOf());
719
818
  }
@@ -728,10 +827,12 @@ export class TimeSpan implements Stringer {
728
827
  return Number(this.valueOf()) / Number(TimeSpan.MILLISECOND.valueOf());
729
828
  }
730
829
 
830
+ /** @returns The number of microseconds in the TimeSpan. */
731
831
  get microseconds(): number {
732
832
  return Number(this.valueOf()) / Number(TimeSpan.MICROSECOND.valueOf());
733
833
  }
734
834
 
835
+ /** @returns The number of nanoseconds in the TimeSpan. */
735
836
  get nanoseconds(): number {
736
837
  return Number(this.valueOf());
737
838
  }
@@ -883,10 +984,12 @@ export class TimeSpan implements Stringer {
883
984
  }
884
985
 
885
986
  /** Rate represents a data rate in Hz. */
886
- export class Rate extends Number implements Stringer {
987
+ export class Rate
988
+ extends primitive.ValueExtension<number>
989
+ implements primitive.Stringer
990
+ {
887
991
  constructor(value: CrudeRate) {
888
- if (value instanceof Number) super(value.valueOf());
889
- else super(value);
992
+ super(value.valueOf());
890
993
  }
891
994
 
892
995
  /** @returns a pretty string representation of the rate in the format "X Hz". */
@@ -979,7 +1082,10 @@ export class Rate extends Number implements Stringer {
979
1082
  }
980
1083
 
981
1084
  /** Density represents the number of bytes in a value. */
982
- export class Density extends Number implements Stringer {
1085
+ export class Density
1086
+ extends primitive.ValueExtension<number>
1087
+ implements primitive.Stringer
1088
+ {
983
1089
  /**
984
1090
  * Creates a Density representing the given number of bytes per value.
985
1091
  *
@@ -988,14 +1094,25 @@ export class Density extends Number implements Stringer {
988
1094
  * @returns A Density representing the given number of bytes per value.
989
1095
  */
990
1096
  constructor(value: CrudeDensity) {
991
- if (value instanceof Number) super(value.valueOf());
992
- else super(value);
1097
+ super(value.valueOf());
993
1098
  }
994
1099
 
1100
+ /**
1101
+ * Calculates the number of values in the given Size.
1102
+ *
1103
+ * @param size - The Size to calculate the value count from.
1104
+ * @returns The number of values in the given Size.
1105
+ */
995
1106
  length(size: Size): number {
996
1107
  return size.valueOf() / this.valueOf();
997
1108
  }
998
1109
 
1110
+ /**
1111
+ * Calculates a Size representing the given number of values.
1112
+ *
1113
+ * @param sampleCount - The number of values in the Size.
1114
+ * @returns A Size representing the given number of values.
1115
+ */
999
1116
  size(sampleCount: number): Size {
1000
1117
  return new Size(sampleCount * this.valueOf());
1001
1118
  }
@@ -1028,7 +1145,7 @@ export class Density extends Number implements Stringer {
1028
1145
  * @property start - A TimeStamp representing the start of the range.
1029
1146
  * @property end - A Timestamp representing the end of the range.
1030
1147
  */
1031
- export class TimeRange implements Stringer {
1148
+ export class TimeRange implements primitive.Stringer {
1032
1149
  /**
1033
1150
  * The starting TimeStamp of the TimeRange.
1034
1151
  *
@@ -1140,10 +1257,20 @@ export class TimeRange implements Stringer {
1140
1257
  return startDist <= delta.valueOf() && endDist <= delta.valueOf();
1141
1258
  }
1142
1259
 
1260
+ /**
1261
+ * Returns a string representation of the TimeRange.
1262
+ *
1263
+ * @returns A string representation of the TimeRange.
1264
+ */
1143
1265
  toString(): string {
1144
1266
  return `${this.start.toString()} - ${this.end.toString()}`;
1145
1267
  }
1146
1268
 
1269
+ /**
1270
+ * Returns a pretty string representation of the TimeRange.
1271
+ *
1272
+ * @returns A pretty string representation of the TimeRange.
1273
+ */
1147
1274
  toPrettyString(): string {
1148
1275
  return `${this.start.fString("preciseDate")} - ${this.span.toString()}`;
1149
1276
  }
@@ -1182,8 +1309,20 @@ export class TimeRange implements Stringer {
1182
1309
  return overlapDuration.greaterThanOrEqual(delta);
1183
1310
  }
1184
1311
 
1312
+ /**
1313
+ * Checks if the TimeRange contains the given TimeRange or TimeStamp.
1314
+ *
1315
+ * @param other - The TimeRange or TimeStamp to check if it is contained in the TimeRange.
1316
+ * @returns True if the TimeRange contains the given TimeRange or TimeStamp.
1317
+ */
1185
1318
  contains(other: TimeRange): boolean;
1186
1319
 
1320
+ /**
1321
+ * Checks if the TimeRange contains the given TimeStamp.
1322
+ *
1323
+ * @param ts - The TimeStamp to check if it is contained in the TimeRange.
1324
+ * @returns True if the TimeRange contains the given TimeStamp.
1325
+ */
1187
1326
  contains(ts: CrudeTimeStamp): boolean;
1188
1327
 
1189
1328
  contains(other: TimeRange | CrudeTimeStamp): boolean {
@@ -1192,6 +1331,17 @@ export class TimeRange implements Stringer {
1192
1331
  return this.start.beforeEq(other) && this.end.after(other);
1193
1332
  }
1194
1333
 
1334
+ /**
1335
+ * Returns a new TimeRange that is bound by the given TimeRange.
1336
+ *
1337
+ * @param other - The TimeRange to bound by.
1338
+ * @returns A new TimeRange that is bound by the given TimeRange.
1339
+ * @example
1340
+ * const range = new TimeRange(new TimeStamp(1000), new TimeStamp(2000));
1341
+ * const other = new TimeRange(new TimeStamp(1500), new TimeStamp(2500));
1342
+ * const bounded = range.boundBy(other);
1343
+ * console.log(bounded); // TimeRange(1500, 2000)
1344
+ */
1195
1345
  boundBy(other: TimeRange): TimeRange {
1196
1346
  const next = new TimeRange(this.start, this.end);
1197
1347
  if (other.start.after(this.start)) next.start = other.start;
@@ -1235,30 +1385,23 @@ export const sortTimeRange = (a: TimeRange, b: TimeRange): -1 | 0 | 1 => {
1235
1385
  };
1236
1386
 
1237
1387
  /** DataType is a string that represents a data type. */
1238
- export class DataType implements Stringer {
1239
- readonly value: string;
1240
- readonly encodeValue = true;
1241
-
1242
- valueOf(): string {
1243
- return this.value;
1244
- }
1245
-
1388
+ export class DataType
1389
+ extends primitive.ValueExtension<string>
1390
+ implements primitive.Stringer
1391
+ {
1246
1392
  constructor(value: CrudeDataType) {
1247
1393
  if (
1248
1394
  value instanceof DataType ||
1249
1395
  typeof value === "string" ||
1250
1396
  typeof value.valueOf() === "string"
1251
- ) {
1252
- this.value = value.valueOf() as string;
1253
- return;
1254
- }
1255
- const t = DataType.ARRAY_CONSTRUCTOR_DATA_TYPES.get(value.constructor.name);
1256
- if (t != null) {
1257
- this.value = t.valueOf();
1258
- return;
1397
+ )
1398
+ super(value.valueOf() as string);
1399
+ else {
1400
+ const t = DataType.ARRAY_CONSTRUCTOR_DATA_TYPES.get(value.constructor.name);
1401
+ if (t == null)
1402
+ throw new Error(`unable to find data type for ${value.toString()}`);
1403
+ super(t.valueOf());
1259
1404
  }
1260
- this.value = DataType.UNKNOWN.valueOf();
1261
- throw new Error(`unable to find data type for ${value.toString()}`);
1262
1405
  }
1263
1406
 
1264
1407
  /**
@@ -1290,31 +1433,60 @@ export class DataType implements Stringer {
1290
1433
  return this.valueOf();
1291
1434
  }
1292
1435
 
1436
+ /**
1437
+ * @returns true if the DataType has a variable density.
1438
+ * @example DataType.STRING.isVariable // true
1439
+ * @example DataType.INT32.isVariable // false
1440
+ */
1293
1441
  get isVariable(): boolean {
1294
1442
  return this.equals(DataType.JSON) || this.equals(DataType.STRING);
1295
1443
  }
1296
1444
 
1445
+ /**
1446
+ * @returns true if the DataType is numeric.
1447
+ * @example DataType.INT32.isNumeric // true
1448
+ * @example DataType.STRING.isNumeric // false
1449
+ */
1297
1450
  get isNumeric(): boolean {
1298
1451
  return !this.isVariable && !this.equals(DataType.UUID);
1299
1452
  }
1300
1453
 
1454
+ /**
1455
+ * @returns true if the DataType is an integer.
1456
+ * @example DataType.INT32.isInteger // true
1457
+ * @example DataType.FLOAT32.isInteger // false
1458
+ */
1301
1459
  get isInteger(): boolean {
1302
1460
  const str = this.toString();
1303
1461
  return str.startsWith("int") || str.startsWith("uint");
1304
1462
  }
1305
1463
 
1464
+ /**
1465
+ * @returns true if the DataType is a floating point number.
1466
+ * @example DataType.FLOAT32.isFloat // true
1467
+ * @example DataType.INT32.isFloat // false
1468
+ */
1306
1469
  get isFloat(): boolean {
1307
1470
  return this.toString().startsWith("float");
1308
1471
  }
1309
1472
 
1473
+ /**
1474
+ * @returns the density of the DataType.
1475
+ * @example DataType.INT16.density // Density.BIT32
1476
+ * @example DataType.FLOAT32.density // Density.BIT32
1477
+ */
1310
1478
  get density(): Density {
1311
1479
  const v = DataType.DENSITIES.get(this.toString());
1312
1480
  if (v == null) throw new Error(`unable to find density for ${this.valueOf()}`);
1313
1481
  return v;
1314
1482
  }
1315
1483
 
1316
- /** @returns ture if the data type is an unsigned numeric integer type */
1317
- get isUnsigned(): boolean {
1484
+ /**
1485
+ * @returns true if the DataType is an unsigned integer.
1486
+ * @example DataType.UINT32.isUnsigned // true
1487
+ * @example DataType.INT32.isUnsigned // false
1488
+ */
1489
+ get isUnsignedInteger(): boolean {
1318
1490
  return (
1319
1491
  this.equals(DataType.UINT8) ||
1320
1492
  this.equals(DataType.UINT16) ||
@@ -1323,8 +1495,12 @@ export class DataType implements Stringer {
1323
1495
  );
1324
1496
  }
1325
1497
 
1326
- /** @returns true if the data type is a signed numeric integer type */
1327
- get isSigned(): boolean {
1498
+ /**
1499
+ * @returns true if the DataType is a signed integer.
1500
+ * @example DataType.INT32.isSigned // true
1501
+ * @example DataType.UINT32.isSigned // false
1502
+ */
1503
+ get isSignedInteger(): boolean {
1328
1504
  return (
1329
1505
  this.equals(DataType.INT8) ||
1330
1506
  this.equals(DataType.INT16) ||
@@ -1338,7 +1514,7 @@ export class DataType implements Stringer {
1338
1514
  if (this.equals(other)) return true;
1339
1515
  if (!this.isNumeric || !other.isNumeric) return false;
1340
1516
  if (this.isVariable || other.isVariable) return false;
1341
- if (this.isUnsigned && other.isSigned) return false;
1517
+ if (this.isUnsignedInteger && other.isSignedInteger) return false;
1342
1518
 
1343
1519
  if (this.isFloat)
1344
1520
  return other.isFloat && this.density.valueOf() <= other.density.valueOf();
@@ -1347,7 +1523,7 @@ export class DataType implements Stringer {
1347
1523
  if (this.isInteger && other.isInteger)
1348
1524
  return (
1349
1525
  this.density.valueOf() <= other.density.valueOf() &&
1350
- this.isUnsigned === other.isUnsigned
1526
+ this.isUnsignedInteger === other.isUnsignedInteger
1351
1527
  );
1352
1528
 
1353
1529
  return false;
@@ -1359,10 +1535,17 @@ export class DataType implements Stringer {
1359
1535
  return this.equals(other);
1360
1536
  }
1361
1537
 
1362
- toJSON(): string {
1363
- return this.toString();
1538
+ /**
1539
+ * Checks whether the given TypedArray is of the same type as the DataType.
1540
+ *
1541
+ * @param array - The TypedArray to check.
1542
+ * @returns True if the TypedArray is of the same type as the DataType.
1543
+ */
1544
+ checkArray(array: TypedArray): boolean {
1545
+ return array.constructor === this.Array;
1364
1546
  }
1365
1547
 
1548
+ /** @returns true if the data type uses bigints to store values. */
1366
1549
  get usesBigInt(): boolean {
1367
1550
  return DataType.BIG_INT_TYPES.some((t) => t.equals(this));
1368
1551
  }
@@ -1402,27 +1585,25 @@ export class DataType implements Stringer {
1402
1585
  * newline character. */
1403
1586
  static readonly JSON = new DataType("json");
1404
1587
 
1405
- static readonly ARRAY_CONSTRUCTORS: Map<string, TypedArrayConstructor> = new Map<
1406
- string,
1407
- TypedArrayConstructor
1408
- >([
1409
- [DataType.UINT8.toString(), Uint8Array],
1410
- [DataType.UINT16.toString(), Uint16Array],
1411
- [DataType.UINT32.toString(), Uint32Array],
1412
- [DataType.UINT64.toString(), BigUint64Array],
1413
- [DataType.FLOAT32.toString(), Float32Array],
1414
- [DataType.FLOAT64.toString(), Float64Array],
1415
- [DataType.INT8.toString(), Int8Array],
1416
- [DataType.INT16.toString(), Int16Array],
1417
- [DataType.INT32.toString(), Int32Array],
1418
- [DataType.INT64.toString(), BigInt64Array],
1419
- [DataType.TIMESTAMP.toString(), BigInt64Array],
1420
- [DataType.STRING.toString(), Uint8Array],
1421
- [DataType.JSON.toString(), Uint8Array],
1422
- [DataType.UUID.toString(), Uint8Array],
1423
- ]);
1424
-
1425
- static readonly ARRAY_CONSTRUCTOR_DATA_TYPES: Map<string, DataType> = new Map<
1588
+ private static readonly ARRAY_CONSTRUCTORS: Map<string, TypedArrayConstructor> =
1589
+ new Map<string, TypedArrayConstructor>([
1590
+ [DataType.UINT8.toString(), Uint8Array],
1591
+ [DataType.UINT16.toString(), Uint16Array],
1592
+ [DataType.UINT32.toString(), Uint32Array],
1593
+ [DataType.UINT64.toString(), BigUint64Array],
1594
+ [DataType.FLOAT32.toString(), Float32Array],
1595
+ [DataType.FLOAT64.toString(), Float64Array],
1596
+ [DataType.INT8.toString(), Int8Array],
1597
+ [DataType.INT16.toString(), Int16Array],
1598
+ [DataType.INT32.toString(), Int32Array],
1599
+ [DataType.INT64.toString(), BigInt64Array],
1600
+ [DataType.TIMESTAMP.toString(), BigInt64Array],
1601
+ [DataType.STRING.toString(), Uint8Array],
1602
+ [DataType.JSON.toString(), Uint8Array],
1603
+ [DataType.UUID.toString(), Uint8Array],
1604
+ ]);
1605
+
1606
+ private static readonly ARRAY_CONSTRUCTOR_DATA_TYPES: Map<string, DataType> = new Map<
1426
1607
  string,
1427
1608
  DataType
1428
1609
  >([
@@ -1438,7 +1619,7 @@ export class DataType implements Stringer {
1438
1619
  [BigInt64Array.name, DataType.INT64],
1439
1620
  ]);
1440
1621
 
1441
- static readonly DENSITIES = new Map<string, Density>([
1622
+ private static readonly DENSITIES = new Map<string, Density>([
1442
1623
  [DataType.UINT8.toString(), Density.BIT8],
1443
1624
  [DataType.UINT16.toString(), Density.BIT16],
1444
1625
  [DataType.UINT32.toString(), Density.BIT32],
@@ -1483,10 +1664,11 @@ export class DataType implements Stringer {
1483
1664
  ]);
1484
1665
  }
1485
1666
 
1486
- /**
1487
- * The Size of an elementy in bytes.
1488
- */
1489
- export class Size extends Number implements Stringer {
1667
+ /** The size of an element in bytes. */
1668
+ export class Size
1669
+ extends primitive.ValueExtension<number>
1670
+ implements primitive.Stringer
1671
+ {
1490
1672
  constructor(value: CrudeSize) {
1491
1673
  super(value.valueOf());
1492
1674
  }
@@ -1501,38 +1683,47 @@ export class Size extends Number implements Stringer {
1501
1683
  return this.valueOf() < other.valueOf();
1502
1684
  }
1503
1685
 
1686
+ /** @returns a new Size representing the sum of the two Sizes. */
1504
1687
  add(other: CrudeSize): Size {
1505
1688
  return Size.bytes(this.valueOf() + other.valueOf());
1506
1689
  }
1507
1690
 
1691
+ /** @returns a new Size representing the difference of the two Sizes. */
1508
1692
  sub(other: CrudeSize): Size {
1509
1693
  return Size.bytes(this.valueOf() - other.valueOf());
1510
1694
  }
1511
1695
 
1696
+ /** @returns a new Size representing the truncated value of the Size. */
1512
1697
  truncate(span: CrudeSize): Size {
1513
1698
  return new Size(Math.trunc(this.valueOf() / span.valueOf()) * span.valueOf());
1514
1699
  }
1515
1700
 
1701
+ /** @returns a new Size representing the remainder of the Size. */
1516
1702
  remainder(span: CrudeSize): Size {
1517
1703
  return Size.bytes(this.valueOf() % span.valueOf());
1518
1704
  }
1519
1705
 
1706
+ /** @returns the number of gigabytes in the Size. */
1520
1707
  get gigabytes(): number {
1521
1708
  return this.valueOf() / Size.GIGABYTE.valueOf();
1522
1709
  }
1523
1710
 
1711
+ /** @returns the number of megabytes in the Size. */
1524
1712
  get megabytes(): number {
1525
1713
  return this.valueOf() / Size.MEGABYTE.valueOf();
1526
1714
  }
1527
1715
 
1716
+ /** @returns the number of kilobytes in the Size. */
1528
1717
  get kilobytes(): number {
1529
1718
  return this.valueOf() / Size.KILOBYTE.valueOf();
1530
1719
  }
1531
1720
 
1721
+ /** @returns the number of terabytes in the Size. */
1532
1722
  get terabytes(): number {
1533
1723
  return this.valueOf() / Size.TERABYTE.valueOf();
1534
1724
  }
1535
1725
 
1726
+ /** @returns a nicely formatted string representation of the Size. */
1536
1727
  toString(): string {
1537
1728
  const totalTB = this.truncate(Size.TERABYTE);
1538
1729
  const totalGB = this.truncate(Size.GIGABYTE);
@@ -1627,6 +1818,7 @@ export class Size extends Number implements Stringer {
1627
1818
  z.instanceof(Size),
1628
1819
  ]);
1629
1820
 
1821
+ /** @returns true if the Size is zero. */
1630
1822
  get isZero(): boolean {
1631
1823
  return this.valueOf() === 0;
1632
1824
  }