@evolu/common 8.4.0 → 8.6.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 (353) hide show
  1. package/dist/src/Array.d.ts +191 -94
  2. package/dist/src/Array.d.ts.map +1 -1
  3. package/dist/src/Array.js +91 -40
  4. package/dist/src/Assert.d.ts +233 -30
  5. package/dist/src/Assert.d.ts.map +1 -1
  6. package/dist/src/Assert.js +151 -30
  7. package/dist/src/BigInt.d.ts +3 -3
  8. package/dist/src/BigInt.js +3 -3
  9. package/dist/src/Brand.d.ts +7 -7
  10. package/dist/src/Buffer.d.ts +12 -4
  11. package/dist/src/Buffer.d.ts.map +1 -1
  12. package/dist/src/Cache.d.ts +8 -3
  13. package/dist/src/Cache.d.ts.map +1 -1
  14. package/dist/src/Cache.js +8 -3
  15. package/dist/src/Callbacks.d.ts +8 -4
  16. package/dist/src/Callbacks.d.ts.map +1 -1
  17. package/dist/src/Console.d.ts +45 -30
  18. package/dist/src/Console.d.ts.map +1 -1
  19. package/dist/src/Console.js +32 -21
  20. package/dist/src/Crypto.d.ts +13 -8
  21. package/dist/src/Crypto.d.ts.map +1 -1
  22. package/dist/src/Crypto.js +6 -3
  23. package/dist/src/Eq.d.ts +107 -58
  24. package/dist/src/Eq.d.ts.map +1 -1
  25. package/dist/src/Eq.js +308 -112
  26. package/dist/src/Function.d.ts +54 -24
  27. package/dist/src/Function.d.ts.map +1 -1
  28. package/dist/src/Function.js +34 -17
  29. package/dist/src/Http.d.ts +52 -19
  30. package/dist/src/Http.d.ts.map +1 -1
  31. package/dist/src/Identicon.d.ts +9 -4
  32. package/dist/src/Identicon.d.ts.map +1 -1
  33. package/dist/src/Identicon.js +9 -4
  34. package/dist/src/LeakDetector.d.ts.map +1 -1
  35. package/dist/src/LeakDetector.js +4 -1
  36. package/dist/src/LockManager.d.ts +12 -10
  37. package/dist/src/LockManager.d.ts.map +1 -1
  38. package/dist/src/Lookup.d.ts +4 -2
  39. package/dist/src/Lookup.d.ts.map +1 -1
  40. package/dist/src/Lookup.js +5 -2
  41. package/dist/src/Number.d.ts +28 -24
  42. package/dist/src/Number.d.ts.map +1 -1
  43. package/dist/src/Number.js +16 -17
  44. package/dist/src/Object.d.ts +89 -47
  45. package/dist/src/Object.d.ts.map +1 -1
  46. package/dist/src/Object.js +88 -41
  47. package/dist/src/Option.d.ts +14 -5
  48. package/dist/src/Option.d.ts.map +1 -1
  49. package/dist/src/Option.js +14 -5
  50. package/dist/src/Order.d.ts +12 -12
  51. package/dist/src/Order.js +12 -12
  52. package/dist/src/Platform.d.ts +2 -2
  53. package/dist/src/Platform.js +1 -0
  54. package/dist/src/Random.d.ts +7 -4
  55. package/dist/src/Random.d.ts.map +1 -1
  56. package/dist/src/Redacted.d.ts +13 -6
  57. package/dist/src/Redacted.d.ts.map +1 -1
  58. package/dist/src/Redacted.js +4 -2
  59. package/dist/src/Ref.d.ts +4 -4
  60. package/dist/src/Relation.d.ts +5 -7
  61. package/dist/src/Relation.d.ts.map +1 -1
  62. package/dist/src/Relation.js +3 -3
  63. package/dist/src/Resource.d.ts +27 -12
  64. package/dist/src/Resource.d.ts.map +1 -1
  65. package/dist/src/Resource.js +9 -3
  66. package/dist/src/Result.d.ts +258 -114
  67. package/dist/src/Result.d.ts.map +1 -1
  68. package/dist/src/Result.js +74 -39
  69. package/dist/src/Schedule.d.ts +233 -116
  70. package/dist/src/Schedule.d.ts.map +1 -1
  71. package/dist/src/Schedule.js +204 -110
  72. package/dist/src/Set.d.ts +43 -24
  73. package/dist/src/Set.d.ts.map +1 -1
  74. package/dist/src/Set.js +25 -13
  75. package/dist/src/Sqlite.d.ts +4 -4
  76. package/dist/src/Sqlite.d.ts.map +1 -1
  77. package/dist/src/Sqlite.js +18 -15
  78. package/dist/src/Store.d.ts.map +1 -1
  79. package/dist/src/Store.js +3 -1
  80. package/dist/src/String.d.ts.map +1 -1
  81. package/dist/src/String.js +1 -1
  82. package/dist/src/Task.d.ts +555 -264
  83. package/dist/src/Task.d.ts.map +1 -1
  84. package/dist/src/Task.js +278 -168
  85. package/dist/src/Test.d.ts +10 -4
  86. package/dist/src/Test.d.ts.map +1 -1
  87. package/dist/src/Test.js +11 -4
  88. package/dist/src/Time.d.ts +27 -17
  89. package/dist/src/Time.d.ts.map +1 -1
  90. package/dist/src/Time.js +25 -8
  91. package/dist/src/Type.d.ts +1218 -372
  92. package/dist/src/Type.d.ts.map +1 -1
  93. package/dist/src/Type.js +1056 -379
  94. package/dist/src/Types.d.ts +95 -40
  95. package/dist/src/Types.d.ts.map +1 -1
  96. package/dist/src/Types.js +13 -4
  97. package/dist/src/WebSocket.d.ts +14 -6
  98. package/dist/src/WebSocket.d.ts.map +1 -1
  99. package/dist/src/WebSocket.js +8 -0
  100. package/dist/src/Worker.d.ts +10 -6
  101. package/dist/src/Worker.d.ts.map +1 -1
  102. package/dist/src/Worker.js +1 -1
  103. package/dist/src/intl/_en.d.ts +3 -1
  104. package/dist/src/intl/_en.d.ts.map +1 -1
  105. package/dist/src/intl/_en.js +17 -3
  106. package/dist/src/intl/ar.d.ts +3 -1
  107. package/dist/src/intl/ar.d.ts.map +1 -1
  108. package/dist/src/intl/ar.js +15 -2
  109. package/dist/src/intl/bn.d.ts +3 -1
  110. package/dist/src/intl/bn.d.ts.map +1 -1
  111. package/dist/src/intl/bn.js +16 -3
  112. package/dist/src/intl/ca.d.ts +3 -1
  113. package/dist/src/intl/ca.d.ts.map +1 -1
  114. package/dist/src/intl/ca.js +16 -3
  115. package/dist/src/intl/cs.d.ts +3 -1
  116. package/dist/src/intl/cs.d.ts.map +1 -1
  117. package/dist/src/intl/cs.js +16 -3
  118. package/dist/src/intl/da.d.ts +3 -1
  119. package/dist/src/intl/da.d.ts.map +1 -1
  120. package/dist/src/intl/da.js +16 -3
  121. package/dist/src/intl/de.d.ts +3 -1
  122. package/dist/src/intl/de.d.ts.map +1 -1
  123. package/dist/src/intl/de.js +16 -3
  124. package/dist/src/intl/el.d.ts +3 -1
  125. package/dist/src/intl/el.d.ts.map +1 -1
  126. package/dist/src/intl/el.js +16 -3
  127. package/dist/src/intl/es.d.ts +3 -1
  128. package/dist/src/intl/es.d.ts.map +1 -1
  129. package/dist/src/intl/es.js +16 -3
  130. package/dist/src/intl/fa.d.ts +3 -1
  131. package/dist/src/intl/fa.d.ts.map +1 -1
  132. package/dist/src/intl/fa.js +16 -3
  133. package/dist/src/intl/fi.d.ts +3 -1
  134. package/dist/src/intl/fi.d.ts.map +1 -1
  135. package/dist/src/intl/fi.js +16 -3
  136. package/dist/src/intl/fil.d.ts +3 -1
  137. package/dist/src/intl/fil.d.ts.map +1 -1
  138. package/dist/src/intl/fil.js +16 -3
  139. package/dist/src/intl/fr.d.ts +3 -1
  140. package/dist/src/intl/fr.d.ts.map +1 -1
  141. package/dist/src/intl/fr.js +16 -3
  142. package/dist/src/intl/he.d.ts +3 -1
  143. package/dist/src/intl/he.d.ts.map +1 -1
  144. package/dist/src/intl/he.js +16 -3
  145. package/dist/src/intl/hi.d.ts +3 -1
  146. package/dist/src/intl/hi.d.ts.map +1 -1
  147. package/dist/src/intl/hi.js +16 -3
  148. package/dist/src/intl/hr.d.ts +3 -1
  149. package/dist/src/intl/hr.d.ts.map +1 -1
  150. package/dist/src/intl/hr.js +16 -3
  151. package/dist/src/intl/hu.d.ts +2 -1
  152. package/dist/src/intl/hu.d.ts.map +1 -1
  153. package/dist/src/intl/hu.js +15 -3
  154. package/dist/src/intl/id.d.ts +3 -1
  155. package/dist/src/intl/id.d.ts.map +1 -1
  156. package/dist/src/intl/id.js +16 -3
  157. package/dist/src/intl/it.d.ts +3 -1
  158. package/dist/src/intl/it.d.ts.map +1 -1
  159. package/dist/src/intl/it.js +16 -3
  160. package/dist/src/intl/ja.d.ts +3 -1
  161. package/dist/src/intl/ja.d.ts.map +1 -1
  162. package/dist/src/intl/ja.js +16 -3
  163. package/dist/src/intl/ko.d.ts +3 -1
  164. package/dist/src/intl/ko.d.ts.map +1 -1
  165. package/dist/src/intl/ko.js +16 -3
  166. package/dist/src/intl/ml.d.ts +3 -1
  167. package/dist/src/intl/ml.d.ts.map +1 -1
  168. package/dist/src/intl/ml.js +16 -3
  169. package/dist/src/intl/mr.d.ts +3 -1
  170. package/dist/src/intl/mr.d.ts.map +1 -1
  171. package/dist/src/intl/mr.js +16 -3
  172. package/dist/src/intl/ms.d.ts +3 -1
  173. package/dist/src/intl/ms.d.ts.map +1 -1
  174. package/dist/src/intl/ms.js +15 -2
  175. package/dist/src/intl/nb.d.ts +2 -1
  176. package/dist/src/intl/nb.d.ts.map +1 -1
  177. package/dist/src/intl/nb.js +14 -2
  178. package/dist/src/intl/nl.d.ts +3 -1
  179. package/dist/src/intl/nl.d.ts.map +1 -1
  180. package/dist/src/intl/nl.js +16 -3
  181. package/dist/src/intl/pa.d.ts +3 -1
  182. package/dist/src/intl/pa.d.ts.map +1 -1
  183. package/dist/src/intl/pa.js +16 -3
  184. package/dist/src/intl/pl.d.ts +2 -0
  185. package/dist/src/intl/pl.d.ts.map +1 -1
  186. package/dist/src/intl/pl.js +15 -2
  187. package/dist/src/intl/pt-BR.d.ts +3 -1
  188. package/dist/src/intl/pt-BR.d.ts.map +1 -1
  189. package/dist/src/intl/pt-BR.js +16 -3
  190. package/dist/src/intl/pt.d.ts +3 -1
  191. package/dist/src/intl/pt.d.ts.map +1 -1
  192. package/dist/src/intl/pt.js +15 -2
  193. package/dist/src/intl/ro.d.ts +3 -1
  194. package/dist/src/intl/ro.d.ts.map +1 -1
  195. package/dist/src/intl/ro.js +16 -3
  196. package/dist/src/intl/sk.d.ts +3 -1
  197. package/dist/src/intl/sk.d.ts.map +1 -1
  198. package/dist/src/intl/sk.js +15 -2
  199. package/dist/src/intl/sl.d.ts +3 -1
  200. package/dist/src/intl/sl.d.ts.map +1 -1
  201. package/dist/src/intl/sl.js +16 -3
  202. package/dist/src/intl/sv.d.ts +3 -1
  203. package/dist/src/intl/sv.d.ts.map +1 -1
  204. package/dist/src/intl/sv.js +16 -3
  205. package/dist/src/intl/sw.d.ts +1 -0
  206. package/dist/src/intl/sw.d.ts.map +1 -1
  207. package/dist/src/intl/sw.js +14 -2
  208. package/dist/src/intl/ta.d.ts +3 -1
  209. package/dist/src/intl/ta.d.ts.map +1 -1
  210. package/dist/src/intl/ta.js +16 -3
  211. package/dist/src/intl/te.d.ts +3 -1
  212. package/dist/src/intl/te.d.ts.map +1 -1
  213. package/dist/src/intl/te.js +16 -3
  214. package/dist/src/intl/th.d.ts +3 -1
  215. package/dist/src/intl/th.d.ts.map +1 -1
  216. package/dist/src/intl/th.js +16 -3
  217. package/dist/src/intl/tr.d.ts +3 -1
  218. package/dist/src/intl/tr.d.ts.map +1 -1
  219. package/dist/src/intl/tr.js +16 -3
  220. package/dist/src/intl/uk.d.ts +3 -1
  221. package/dist/src/intl/uk.d.ts.map +1 -1
  222. package/dist/src/intl/uk.js +16 -3
  223. package/dist/src/intl/ur.d.ts +3 -1
  224. package/dist/src/intl/ur.d.ts.map +1 -1
  225. package/dist/src/intl/ur.js +15 -2
  226. package/dist/src/intl/vi.d.ts +3 -1
  227. package/dist/src/intl/vi.d.ts.map +1 -1
  228. package/dist/src/intl/vi.js +16 -3
  229. package/dist/src/intl/zh-CN.d.ts +3 -1
  230. package/dist/src/intl/zh-CN.d.ts.map +1 -1
  231. package/dist/src/intl/zh-CN.js +16 -3
  232. package/dist/src/intl/zh-TW.d.ts +3 -1
  233. package/dist/src/intl/zh-TW.d.ts.map +1 -1
  234. package/dist/src/intl/zh-TW.js +16 -3
  235. package/dist/src/local-first/Db.js +3 -2
  236. package/dist/src/local-first/Evolu.d.ts +47 -24
  237. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  238. package/dist/src/local-first/Evolu.js +1 -0
  239. package/dist/src/local-first/Owner.d.ts +18 -14
  240. package/dist/src/local-first/Owner.d.ts.map +1 -1
  241. package/dist/src/local-first/Owner.js +14 -11
  242. package/dist/src/local-first/Protocol.d.ts +5 -5
  243. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  244. package/dist/src/local-first/Protocol.js +35 -29
  245. package/dist/src/local-first/Query.d.ts +34 -21
  246. package/dist/src/local-first/Query.d.ts.map +1 -1
  247. package/dist/src/local-first/Query.js +27 -14
  248. package/dist/src/local-first/Relay.d.ts +12 -5
  249. package/dist/src/local-first/Relay.d.ts.map +1 -1
  250. package/dist/src/local-first/Relay.js +1 -1
  251. package/dist/src/local-first/Schema.d.ts +19 -11
  252. package/dist/src/local-first/Schema.d.ts.map +1 -1
  253. package/dist/src/local-first/Schema.js +11 -6
  254. package/dist/src/local-first/Shared.d.ts.map +1 -1
  255. package/dist/src/local-first/Shared.js +4 -2
  256. package/dist/src/local-first/Storage.d.ts +4 -2
  257. package/dist/src/local-first/Storage.d.ts.map +1 -1
  258. package/dist/src/local-first/Timestamp.d.ts.map +1 -1
  259. package/dist/src/local-first/Timestamp.js +1 -1
  260. package/package.json +3 -4
  261. package/src/Array.ts +195 -95
  262. package/src/Assert.ts +337 -31
  263. package/src/BigInt.ts +3 -3
  264. package/src/Brand.ts +7 -7
  265. package/src/Buffer.ts +12 -4
  266. package/src/Cache.ts +8 -3
  267. package/src/Callbacks.ts +8 -4
  268. package/src/Console.ts +45 -30
  269. package/src/Crypto.ts +13 -8
  270. package/src/Eq.ts +450 -122
  271. package/src/Function.ts +54 -24
  272. package/src/Http.ts +52 -19
  273. package/src/Identicon.ts +9 -4
  274. package/src/LeakDetector.ts +4 -3
  275. package/src/LockManager.ts +12 -10
  276. package/src/Lookup.ts +5 -2
  277. package/src/Number.ts +28 -24
  278. package/src/Object.ts +115 -49
  279. package/src/Option.ts +14 -5
  280. package/src/Order.ts +12 -12
  281. package/src/Platform.ts +3 -2
  282. package/src/Random.ts +7 -4
  283. package/src/Redacted.ts +13 -6
  284. package/src/Ref.ts +4 -4
  285. package/src/Relation.ts +8 -10
  286. package/src/Resource.ts +36 -15
  287. package/src/Result.ts +263 -119
  288. package/src/Schedule.ts +233 -116
  289. package/src/Set.ts +43 -24
  290. package/src/Sqlite.ts +18 -15
  291. package/src/Store.ts +3 -1
  292. package/src/String.ts +1 -1
  293. package/src/Task.ts +566 -286
  294. package/src/Test.ts +11 -4
  295. package/src/Time.ts +36 -19
  296. package/src/Type.ts +2191 -590
  297. package/src/Types.ts +108 -40
  298. package/src/WebSocket.ts +22 -6
  299. package/src/Worker.ts +11 -7
  300. package/src/intl/_en.ts +20 -4
  301. package/src/intl/ar.ts +17 -2
  302. package/src/intl/bn.ts +19 -4
  303. package/src/intl/ca.ts +19 -4
  304. package/src/intl/cs.ts +19 -4
  305. package/src/intl/da.ts +19 -4
  306. package/src/intl/de.ts +19 -4
  307. package/src/intl/el.ts +19 -4
  308. package/src/intl/es.ts +19 -4
  309. package/src/intl/fa.ts +19 -4
  310. package/src/intl/fi.ts +19 -4
  311. package/src/intl/fil.ts +19 -4
  312. package/src/intl/fr.ts +19 -4
  313. package/src/intl/he.ts +19 -4
  314. package/src/intl/hi.ts +19 -4
  315. package/src/intl/hr.ts +19 -4
  316. package/src/intl/hu.ts +18 -4
  317. package/src/intl/id.ts +19 -4
  318. package/src/intl/it.ts +19 -4
  319. package/src/intl/ja.ts +19 -4
  320. package/src/intl/ko.ts +19 -4
  321. package/src/intl/ml.ts +19 -4
  322. package/src/intl/mr.ts +19 -4
  323. package/src/intl/ms.ts +17 -2
  324. package/src/intl/nb.ts +16 -2
  325. package/src/intl/nl.ts +19 -4
  326. package/src/intl/pa.ts +19 -4
  327. package/src/intl/pl.ts +18 -2
  328. package/src/intl/pt-BR.ts +19 -4
  329. package/src/intl/pt.ts +17 -2
  330. package/src/intl/ro.ts +19 -4
  331. package/src/intl/sk.ts +17 -2
  332. package/src/intl/sl.ts +19 -4
  333. package/src/intl/sv.ts +19 -4
  334. package/src/intl/sw.ts +15 -2
  335. package/src/intl/ta.ts +19 -4
  336. package/src/intl/te.ts +19 -4
  337. package/src/intl/th.ts +19 -4
  338. package/src/intl/tr.ts +19 -4
  339. package/src/intl/uk.ts +19 -4
  340. package/src/intl/ur.ts +17 -2
  341. package/src/intl/vi.ts +19 -3
  342. package/src/intl/zh-CN.ts +19 -4
  343. package/src/intl/zh-TW.ts +19 -4
  344. package/src/local-first/Db.ts +2 -1
  345. package/src/local-first/Evolu.ts +48 -24
  346. package/src/local-first/Owner.ts +18 -14
  347. package/src/local-first/Protocol.ts +45 -35
  348. package/src/local-first/Query.ts +40 -24
  349. package/src/local-first/Relay.ts +13 -6
  350. package/src/local-first/Schema.ts +19 -11
  351. package/src/local-first/Shared.ts +4 -2
  352. package/src/local-first/Storage.ts +4 -2
  353. package/src/local-first/Timestamp.ts +1 -1
package/dist/src/Eq.d.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  * @module
5
5
  */
6
6
  import type { Order } from "./Order.ts";
7
- import type { JsonValue, JsonValueInput } from "./Type.ts";
7
+ import type { IsData, JsonValue, JsonValueInput } from "./Type.ts";
8
+ import type { CompileTimeError } from "./Types.ts";
8
9
  /**
9
10
  * Compares two values of the same type `A` for equality.
10
11
  *
@@ -22,47 +23,61 @@ import type { JsonValue, JsonValueInput } from "./Type.ts";
22
23
  * ### Example
23
24
  *
24
25
  * ```ts
25
- * import { createEqObject, eqNumber } from "@evolu/common";
26
+ * import {
27
+ * assertFalse,
28
+ * assertTrue,
29
+ * createEqObject,
30
+ * eqNumber,
31
+ * } from "@evolu/common";
26
32
  *
27
33
  * const eqPoint = createEqObject({ x: eqNumber, y: eqNumber });
28
34
  *
29
- * expect(eqPoint({ x: 1, y: 2 }, { x: 1, y: 2 })).toBe(true);
30
- * expect(eqPoint({ x: 1, y: 2 }, { x: 2, y: 1 })).toBe(false);
35
+ * assertTrue(eqPoint({ x: 1, y: 2 }, { x: 1, y: 2 }));
36
+ * assertFalse(eqPoint({ x: 1, y: 2 }, { x: 2, y: 1 }));
31
37
  * ```
32
38
  */
33
39
  export type Eq<in A> = (x: A, y: A) => boolean;
34
40
  /**
35
- * Compares two values with strict equality (`===`).
41
+ * Compares two values using SameValue equality (`Object.is`).
36
42
  *
37
- * Strict equality considers `NaN` unequal to itself. Use {@link eqSameValueZero}
38
- * when values can contain `NaN` and equality must be reflexive.
43
+ * SameValue considers `NaN` equal to itself, distinguishes `0` from `-0`, and
44
+ * compares objects by reference identity.
45
+ *
46
+ * ### Example
47
+ *
48
+ * ```ts
49
+ * import { assertFalse, assertTrue, eqStrict } from "@evolu/common";
50
+ *
51
+ * assertTrue(eqStrict(NaN, NaN));
52
+ * assertFalse(eqStrict(0, -0));
53
+ * ```
39
54
  */
40
55
  export declare const eqStrict: <A>(x: A, y: A) => boolean;
41
56
  /**
42
57
  * Compares two values using SameValueZero equality.
43
58
  *
44
59
  * SameValueZero is the standard equality algorithm used by `Map`, `Set`, and
45
- * `Array.prototype.includes`. It behaves like strict equality except that `NaN`
46
- * equals itself. Both algorithms consider `0` and `-0` equal.
60
+ * `Array.prototype.includes`. Like SameValue, it considers `NaN` equal to
61
+ * itself, but unlike SameValue, it considers `0` and `-0` equal.
47
62
  *
48
63
  * ### Example
49
64
  *
50
65
  * ```ts
51
- * import { eqSameValueZero } from "@evolu/common";
66
+ * import { assertFalse, assertTrue, eqSameValueZero } from "@evolu/common";
52
67
  *
53
- * expect(eqSameValueZero(NaN, NaN)).toBe(true);
54
- * expect(eqSameValueZero(0, -0)).toBe(true);
55
- * expect(eqSameValueZero({}, {})).toBe(false);
68
+ * assertTrue(eqSameValueZero(NaN, NaN));
69
+ * assertTrue(eqSameValueZero(0, -0));
70
+ * assertFalse(eqSameValueZero({}, {}));
56
71
  * ```
57
72
  */
58
73
  export declare const eqSameValueZero: <A>(x: A, y: A) => boolean;
59
- /** An {@link Eq} for strings using strict equality. */
74
+ /** An {@link Eq} for strings using {@link eqStrict}. */
60
75
  export declare const eqString: Eq<string>;
61
76
  /** An {@link Eq} for numbers using {@link eqSameValueZero}. */
62
77
  export declare const eqNumber: Eq<number>;
63
- /** An {@link Eq} for bigints using strict equality. */
78
+ /** An {@link Eq} for bigints using {@link eqStrict}. */
64
79
  export declare const eqBigInt: Eq<bigint>;
65
- /** An {@link Eq} for booleans using strict equality. */
80
+ /** An {@link Eq} for booleans using {@link eqStrict}. */
66
81
  export declare const eqBoolean: Eq<boolean>;
67
82
  /** An {@link Eq} for `undefined`. */
68
83
  export declare const eqUndefined: Eq<undefined>;
@@ -77,32 +92,38 @@ export declare const eqFromOrder: <A>(order: Order<A>) => Eq<A>;
77
92
  * ### Example
78
93
  *
79
94
  * ```ts
80
- * import { createEqArrayLike, eqNumber } from "@evolu/common";
95
+ * import {
96
+ * assertFalse,
97
+ * assertTrue,
98
+ * createEqArrayLike,
99
+ * eqNumber,
100
+ * } from "@evolu/common";
81
101
  *
82
102
  * const eqArrayNumber = createEqArrayLike(eqNumber);
83
103
  *
84
- * expect(eqArrayNumber([1, 2, 3], [1, 2, 3])).toBe(true);
85
- * expect(
104
+ * assertTrue(eqArrayNumber([1, 2, 3], [1, 2, 3]));
105
+ * assertTrue(
86
106
  * eqArrayNumber(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 3])),
87
- * ).toBe(true);
88
- * expect(eqArrayNumber([1, 2, 3], [1, 2, 4])).toBe(false);
107
+ * );
108
+ * assertFalse(eqArrayNumber([1, 2, 3], [1, 2, 4]));
89
109
  * ```
90
110
  */
91
111
  export declare const createEqArrayLike: <A>(item: Eq<A>) => Eq<ArrayLike<A>>;
92
112
  /**
93
- * Compares two array-like structures by strict reference equality (`===`).
113
+ * Compares two array-like structures element by element using {@link eqStrict}.
94
114
  *
95
- * Useful for structural sharing checks where elements are compared by identity.
115
+ * Useful for structural sharing checks where objects are compared by reference
116
+ * identity. `NaN` elements are equal, while `0` and `-0` elements differ.
96
117
  *
97
118
  * ### Example
98
119
  *
99
120
  * ```ts
100
- * import { eqArrayStrict } from "@evolu/common";
121
+ * import { assertFalse, assertTrue, eqArrayStrict } from "@evolu/common";
101
122
  *
102
123
  * const a = { x: 1 };
103
124
  * const b = { x: 1 };
104
- * expect(eqArrayStrict([a, a], [a, a])).toBe(true);
105
- * expect(eqArrayStrict([a], [b])).toBe(false);
125
+ * assertTrue(eqArrayStrict([a, a], [a, a]));
126
+ * assertFalse(eqArrayStrict([a], [b]));
106
127
  * ```
107
128
  */
108
129
  export declare const eqArrayStrict: <A>(x: ArrayLike<A>, y: ArrayLike<A>) => boolean;
@@ -112,12 +133,27 @@ export declare const eqArrayStrict: <A>(x: ArrayLike<A>, y: ArrayLike<A>) => boo
112
133
  * ### Example
113
134
  *
114
135
  * ```ts
115
- * import { eqArrayNumber } from "@evolu/common";
136
+ * import { assertTrue, eqArrayNumber } from "@evolu/common";
116
137
  *
117
- * expect(eqArrayNumber([1, NaN], [1, NaN])).toBe(true);
138
+ * assertTrue(eqArrayNumber([1, NaN], [1, NaN]));
118
139
  * ```
119
140
  */
120
141
  export declare const eqArrayNumber: Eq<ArrayLike<number>>;
142
+ /**
143
+ * Compares two Uint8Arrays by byte value.
144
+ *
145
+ * ### Example
146
+ *
147
+ * ```ts
148
+ * import { assertFalse, assertTrue, eqUint8Array } from "@evolu/common";
149
+ *
150
+ * assertTrue(eqUint8Array(new Uint8Array([1, 2]), new Uint8Array([1, 2])));
151
+ * assertFalse(
152
+ * eqUint8Array(new Uint8Array([1, 2]), new Uint8Array([1, 3])),
153
+ * );
154
+ * ```
155
+ */
156
+ export declare const eqUint8Array: Eq<Uint8Array>;
121
157
  /**
122
158
  * Creates an equivalence function for objects based on an equivalence for their
123
159
  * fields.
@@ -125,59 +161,72 @@ export declare const eqArrayNumber: Eq<ArrayLike<number>>;
125
161
  * ### Example
126
162
  *
127
163
  * ```ts
128
- * import { createEqObject, eqNumber } from "@evolu/common";
164
+ * import {
165
+ * assertFalse,
166
+ * assertTrue,
167
+ * createEqObject,
168
+ * eqNumber,
169
+ * } from "@evolu/common";
129
170
  *
130
171
  * const eqObjectNumber = createEqObject({ a: eqNumber });
131
172
  *
132
- * expect(eqObjectNumber({ a: 1 }, { a: 1 })).toBe(true);
133
- * expect(eqObjectNumber({ a: 1 }, { a: 2 })).toBe(false);
173
+ * assertTrue(eqObjectNumber({ a: 1 }, { a: 1 }));
174
+ * assertFalse(eqObjectNumber({ a: 1 }, { a: 2 }));
134
175
  * ```
135
176
  */
136
177
  export declare const createEqObject: <A>(eqs: { [K in keyof A]: Eq<A[K]>; }) => Eq<{ readonly [K in keyof A]: A[K]; }>;
137
178
  /**
138
- * Deeply compares two {@link JsonValue} values for equality.
179
+ * Compares two {@link Data} values.
139
180
  *
140
- * - Uses an iterative approach with a stack to handle large or deeply nested
141
- * objects without risking stack overflow.
142
- * - Defensively handles circular references in runtime values without looping,
143
- * although cyclic values are not valid JSON.
144
- * - Unlike JSON.stringify, this function directly compares values, avoiding
145
- * serialization overhead and leveraging short-circuit evaluation for faster
146
- * failure on mismatched structures.
181
+ * Primitive values use SameValueZero, so `NaN` equals itself and `0` equals
182
+ * `-0`. Arrays and Object properties are ordered and keyed respectively. Sets
183
+ * and Maps compare their elements and entries without regard to insertion
184
+ * order. Dates compare their time values, while Uint8Arrays compare their
185
+ * bytes. Cyclic and shared data graphs are supported.
186
+ *
187
+ * The compile-time validation recursively accepts ordinary interfaces whose
188
+ * properties consist only of Data. Runtime representation details are trusted;
189
+ * use the {@link Data} Type at an unknown boundary.
147
190
  *
148
191
  * ### Example
149
192
  *
150
193
  * ```ts
151
- * import { eqJsonValue, type JsonValue } from "@evolu/common";
194
+ * import { assertTrue, eqData } from "@evolu/common";
152
195
  *
153
- * const first: JsonValue = { profile: { name: "Ada" } };
154
- * const second: JsonValue = { profile: { name: "Ada" } };
196
+ * interface User {
197
+ * readonly name: string;
198
+ * readonly roles: ReadonlySet<string>;
199
+ * }
200
+ *
201
+ * const first: User = { name: "Ada", roles: new Set(["admin", "author"]) };
202
+ * const second: User = {
203
+ * name: "Ada",
204
+ * roles: new Set(["author", "admin"]),
205
+ * };
155
206
  *
156
- * expect(eqJsonValue(first, second)).toBe(true);
207
+ * assertTrue(eqData(first, second));
157
208
  * ```
158
209
  */
159
- export declare const eqJsonValue: (a: JsonValue, b: JsonValue) => boolean;
210
+ export declare function eqData<Actual, Expected>(actual: Actual, expected: Expected, ...dataError: EqDataError<Actual | Expected>): boolean;
160
211
  /**
161
- * Deeply compares two {@link JsonValueInput} values for equality.
162
- *
163
- * - Uses an iterative approach with a stack to handle large or deeply nested
164
- * objects without risking stack overflow.
165
- * - Defensively handles circular references in runtime values without looping,
166
- * although cyclic values are not valid JSON.
167
- * - Unlike JSON.stringify, this function directly compares values, avoiding
168
- * serialization overhead and leveraging short-circuit evaluation for faster
169
- * failure on mismatched structures.
212
+ * Compares two {@link JsonValue} values using {@link eqData}.
170
213
  *
171
214
  * ### Example
172
215
  *
173
216
  * ```ts
174
- * import { eqJsonValueInput, type JsonValueInput } from "@evolu/common";
217
+ * import { assertTrue, eqJsonValue, type JsonValue } from "@evolu/common";
175
218
  *
176
- * const first: JsonValueInput = { profile: { name: "Ada" } };
177
- * const second: JsonValueInput = { profile: { name: "Ada" } };
219
+ * const first: JsonValue = { profile: { name: "Ada" } };
220
+ * const second: JsonValue = { profile: { name: "Ada" } };
178
221
  *
179
- * expect(eqJsonValueInput(first, second)).toBe(true);
222
+ * assertTrue(eqJsonValue(first, second));
180
223
  * ```
181
224
  */
182
- export declare const eqJsonValueInput: (a: JsonValueInput, b: JsonValueInput) => boolean;
225
+ export declare const eqJsonValue: Eq<JsonValue>;
226
+ /** Compares two {@link JsonValueInput} values using {@link eqData}. */
227
+ export declare const eqJsonValueInput: Eq<JsonValueInput>;
228
+ type EqDataError<Value> = IsData<Value> extends true ? [] : [
229
+ error: CompileTimeError<"eqData", "Actual and expected values must consist only of Data.">
230
+ ];
231
+ export {};
183
232
  //# sourceMappingURL=Eq.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Eq.d.ts","sourceRoot":"","sources":["../../src/Eq.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAGV,SAAS,EACT,cAA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