@evolu/common 7.4.1 → 8.0.0-next.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 (251) hide show
  1. package/README.md +4 -61
  2. package/dist/src/Array.d.ts +343 -102
  3. package/dist/src/Array.d.ts.map +1 -1
  4. package/dist/src/Array.js +181 -85
  5. package/dist/src/Assert.d.ts +57 -11
  6. package/dist/src/Assert.d.ts.map +1 -1
  7. package/dist/src/Assert.js +47 -11
  8. package/dist/src/BigInt.d.ts +6 -1
  9. package/dist/src/BigInt.d.ts.map +1 -1
  10. package/dist/src/BigInt.js +5 -0
  11. package/dist/src/Brand.d.ts +40 -12
  12. package/dist/src/Brand.d.ts.map +1 -1
  13. package/dist/src/Brand.js +5 -0
  14. package/dist/src/Buffer.d.ts +6 -1
  15. package/dist/src/Buffer.d.ts.map +1 -1
  16. package/dist/src/Buffer.js +7 -2
  17. package/dist/src/Cache.d.ts +10 -2
  18. package/dist/src/Cache.d.ts.map +1 -1
  19. package/dist/src/Cache.js +6 -0
  20. package/dist/src/Callbacks.d.ts +10 -7
  21. package/dist/src/Callbacks.d.ts.map +1 -1
  22. package/dist/src/Callbacks.js +23 -13
  23. package/dist/src/Console.d.ts +361 -69
  24. package/dist/src/Console.d.ts.map +1 -1
  25. package/dist/src/Console.js +217 -117
  26. package/dist/src/Crypto.d.ts +70 -21
  27. package/dist/src/Crypto.d.ts.map +1 -1
  28. package/dist/src/Crypto.js +72 -27
  29. package/dist/src/Eq.d.ts +22 -2
  30. package/dist/src/Eq.d.ts.map +1 -1
  31. package/dist/src/Eq.js +21 -1
  32. package/dist/src/Error.d.ts +23 -12
  33. package/dist/src/Error.d.ts.map +1 -1
  34. package/dist/src/Error.js +27 -11
  35. package/dist/src/Function.d.ts +128 -56
  36. package/dist/src/Function.d.ts.map +1 -1
  37. package/dist/src/Function.js +118 -14
  38. package/dist/src/Identicon.d.ts +5 -0
  39. package/dist/src/Identicon.d.ts.map +1 -1
  40. package/dist/src/Identicon.js +6 -1
  41. package/dist/src/Lookup.d.ts +160 -0
  42. package/dist/src/Lookup.d.ts.map +1 -0
  43. package/dist/src/Lookup.js +192 -0
  44. package/dist/src/Microtask.d.ts +21 -0
  45. package/dist/src/Microtask.d.ts.map +1 -0
  46. package/dist/src/Microtask.js +37 -0
  47. package/dist/src/Number.d.ts +18 -4
  48. package/dist/src/Number.d.ts.map +1 -1
  49. package/dist/src/Number.js +23 -1
  50. package/dist/src/Object.d.ts +110 -5
  51. package/dist/src/Object.d.ts.map +1 -1
  52. package/dist/src/Object.js +108 -5
  53. package/dist/src/Option.d.ts +58 -0
  54. package/dist/src/Option.d.ts.map +1 -0
  55. package/dist/src/Option.js +43 -0
  56. package/dist/src/Order.d.ts +5 -0
  57. package/dist/src/Order.d.ts.map +1 -1
  58. package/dist/src/Order.js +8 -3
  59. package/dist/src/Platform.d.ts +36 -2
  60. package/dist/src/Platform.d.ts.map +1 -1
  61. package/dist/src/Platform.js +10 -6
  62. package/dist/src/Polyfills.d.ts +27 -0
  63. package/dist/src/Polyfills.d.ts.map +1 -0
  64. package/dist/src/Polyfills.js +299 -0
  65. package/dist/src/Random.d.ts +18 -7
  66. package/dist/src/Random.d.ts.map +1 -1
  67. package/dist/src/Random.js +9 -7
  68. package/dist/src/Redacted.d.ts +7 -4
  69. package/dist/src/Redacted.d.ts.map +1 -1
  70. package/dist/src/Redacted.js +5 -0
  71. package/dist/src/Ref.d.ts +31 -16
  72. package/dist/src/Ref.d.ts.map +1 -1
  73. package/dist/src/Ref.js +35 -7
  74. package/dist/src/RefCount.d.ts +62 -0
  75. package/dist/src/RefCount.d.ts.map +1 -0
  76. package/dist/src/RefCount.js +83 -0
  77. package/dist/src/Relation.d.ts +84 -29
  78. package/dist/src/Relation.d.ts.map +1 -1
  79. package/dist/src/Relation.js +83 -105
  80. package/dist/src/Resource.d.ts +263 -0
  81. package/dist/src/Resource.d.ts.map +1 -0
  82. package/dist/src/Resource.js +389 -0
  83. package/dist/src/Result.d.ts +390 -374
  84. package/dist/src/Result.d.ts.map +1 -1
  85. package/dist/src/Result.js +142 -70
  86. package/dist/src/Schedule.d.ts +953 -0
  87. package/dist/src/Schedule.d.ts.map +1 -0
  88. package/dist/src/Schedule.js +1199 -0
  89. package/dist/src/Set.d.ts +181 -0
  90. package/dist/src/Set.d.ts.map +1 -0
  91. package/dist/src/Set.js +137 -0
  92. package/dist/src/Skiplist.d.ts +6 -1
  93. package/dist/src/Skiplist.d.ts.map +1 -1
  94. package/dist/src/Skiplist.js +5 -0
  95. package/dist/src/Sqlite.d.ts +160 -60
  96. package/dist/src/Sqlite.d.ts.map +1 -1
  97. package/dist/src/Sqlite.js +290 -190
  98. package/dist/src/Store.d.ts +36 -28
  99. package/dist/src/Store.d.ts.map +1 -1
  100. package/dist/src/Store.js +55 -15
  101. package/dist/src/String.d.ts +5 -0
  102. package/dist/src/String.d.ts.map +1 -1
  103. package/dist/src/String.js +5 -0
  104. package/dist/src/Task.d.ts +2263 -423
  105. package/dist/src/Task.d.ts.map +1 -1
  106. package/dist/src/Task.js +1488 -348
  107. package/dist/src/Test.d.ts +122 -0
  108. package/dist/src/Test.d.ts.map +1 -0
  109. package/dist/src/Test.js +66 -0
  110. package/dist/src/Time.d.ts +201 -48
  111. package/dist/src/Time.d.ts.map +1 -1
  112. package/dist/src/Time.js +190 -86
  113. package/dist/src/Tracer.d.ts +48 -0
  114. package/dist/src/Tracer.d.ts.map +1 -0
  115. package/dist/src/Tracer.js +6 -0
  116. package/dist/src/Type.d.ts +582 -209
  117. package/dist/src/Type.d.ts.map +1 -1
  118. package/dist/src/Type.js +362 -240
  119. package/dist/src/Types.d.ts +160 -6
  120. package/dist/src/Types.d.ts.map +1 -1
  121. package/dist/src/Types.js +22 -2
  122. package/dist/src/WebSocket.d.ts +113 -58
  123. package/dist/src/WebSocket.d.ts.map +1 -1
  124. package/dist/src/WebSocket.js +210 -118
  125. package/dist/src/Worker.d.ts +245 -60
  126. package/dist/src/Worker.d.ts.map +1 -1
  127. package/dist/src/Worker.js +220 -64
  128. package/dist/src/index.d.ts +25 -3
  129. package/dist/src/index.d.ts.map +1 -1
  130. package/dist/src/index.js +19 -3
  131. package/dist/src/local-first/Db.d.ts +24 -213
  132. package/dist/src/local-first/Db.d.ts.map +1 -1
  133. package/dist/src/local-first/Db.js +622 -293
  134. package/dist/src/local-first/Error.d.ts +12 -0
  135. package/dist/src/local-first/Error.d.ts.map +1 -0
  136. package/dist/src/local-first/Error.js +6 -0
  137. package/dist/src/local-first/Evolu.d.ts +330 -285
  138. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  139. package/dist/src/local-first/Evolu.js +472 -402
  140. package/dist/src/local-first/LocalAuth.d.ts +10 -10
  141. package/dist/src/local-first/LocalAuth.d.ts.map +1 -1
  142. package/dist/src/local-first/LocalAuth.js +6 -1
  143. package/dist/src/local-first/Owner.d.ts +70 -27
  144. package/dist/src/local-first/Owner.d.ts.map +1 -1
  145. package/dist/src/local-first/Owner.js +27 -14
  146. package/dist/src/local-first/Protocol.d.ts +58 -50
  147. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  148. package/dist/src/local-first/Protocol.js +253 -155
  149. package/dist/src/local-first/Query.d.ts +133 -43
  150. package/dist/src/local-first/Query.d.ts.map +1 -1
  151. package/dist/src/local-first/Query.js +139 -90
  152. package/dist/src/local-first/Relay.d.ts +18 -38
  153. package/dist/src/local-first/Relay.d.ts.map +1 -1
  154. package/dist/src/local-first/Relay.js +59 -171
  155. package/dist/src/local-first/Schema.d.ts +139 -144
  156. package/dist/src/local-first/Schema.d.ts.map +1 -1
  157. package/dist/src/local-first/Schema.js +78 -163
  158. package/dist/src/local-first/Shared.d.ts +125 -0
  159. package/dist/src/local-first/Shared.d.ts.map +1 -0
  160. package/dist/src/local-first/Shared.js +569 -0
  161. package/dist/src/local-first/Storage.d.ts +50 -53
  162. package/dist/src/local-first/Storage.d.ts.map +1 -1
  163. package/dist/src/local-first/Storage.js +121 -173
  164. package/dist/src/local-first/Timestamp.d.ts +28 -35
  165. package/dist/src/local-first/Timestamp.d.ts.map +1 -1
  166. package/dist/src/local-first/Timestamp.js +24 -25
  167. package/dist/src/local-first/index.d.ts +2 -15
  168. package/dist/src/local-first/index.d.ts.map +1 -1
  169. package/dist/src/local-first/index.js +2 -15
  170. package/package.json +36 -26
  171. package/src/Array.ts +467 -106
  172. package/src/Assert.ts +87 -12
  173. package/src/BigInt.ts +7 -1
  174. package/src/Brand.ts +41 -12
  175. package/src/Buffer.ts +10 -4
  176. package/src/Cache.ts +11 -2
  177. package/src/Callbacks.ts +33 -23
  178. package/src/Console.ts +567 -178
  179. package/src/Crypto.ts +111 -62
  180. package/src/Eq.ts +30 -3
  181. package/src/Error.ts +50 -34
  182. package/src/Function.ts +140 -68
  183. package/src/Identicon.ts +7 -1
  184. package/src/Lookup.ts +415 -0
  185. package/src/Microtask.ts +58 -0
  186. package/src/Number.ts +40 -7
  187. package/src/Object.ts +155 -16
  188. package/src/Option.ts +74 -0
  189. package/src/Order.ts +11 -3
  190. package/src/Platform.ts +43 -7
  191. package/src/Polyfills.ts +465 -0
  192. package/src/Random.ts +25 -11
  193. package/src/Redacted.ts +8 -4
  194. package/src/Ref.ts +72 -21
  195. package/src/RefCount.ts +170 -0
  196. package/src/Relation.ts +188 -136
  197. package/src/Resource.ts +864 -0
  198. package/src/Result.ts +548 -381
  199. package/src/Schedule.ts +1471 -0
  200. package/src/Set.ts +247 -0
  201. package/src/Skiplist.ts +7 -1
  202. package/src/Sqlite.ts +409 -304
  203. package/src/Store.ts +94 -48
  204. package/src/String.ts +6 -0
  205. package/src/Task.ts +3685 -740
  206. package/src/Test.ts +162 -0
  207. package/src/Time.ts +348 -145
  208. package/src/Tracer.ts +54 -0
  209. package/src/Type.ts +851 -430
  210. package/src/Types.ts +202 -7
  211. package/src/WebSocket.ts +311 -178
  212. package/src/Worker.ts +527 -147
  213. package/src/index.ts +74 -3
  214. package/src/local-first/Db.ts +871 -597
  215. package/src/local-first/Error.ts +17 -0
  216. package/src/local-first/Evolu.ts +884 -824
  217. package/src/local-first/LocalAuth.ts +10 -10
  218. package/src/local-first/Owner.ts +94 -42
  219. package/src/local-first/Protocol.ts +440 -303
  220. package/src/local-first/Query.ts +243 -194
  221. package/src/local-first/Relay.ts +91 -252
  222. package/src/local-first/Schema.ts +284 -394
  223. package/src/local-first/Shared.ts +932 -0
  224. package/src/local-first/Storage.ts +206 -277
  225. package/src/local-first/Timestamp.ts +38 -45
  226. package/src/local-first/index.ts +2 -16
  227. package/LICENSE +0 -21
  228. package/dist/src/Instances.d.ts +0 -34
  229. package/dist/src/Instances.d.ts.map +0 -1
  230. package/dist/src/Instances.js +0 -44
  231. package/dist/src/Resources.d.ts +0 -118
  232. package/dist/src/Resources.d.ts.map +0 -1
  233. package/dist/src/Resources.js +0 -197
  234. package/dist/src/local-first/Platform.d.ts +0 -25
  235. package/dist/src/local-first/Platform.d.ts.map +0 -1
  236. package/dist/src/local-first/Platform.js +0 -1
  237. package/dist/src/local-first/Public.d.ts +0 -22
  238. package/dist/src/local-first/Public.d.ts.map +0 -1
  239. package/dist/src/local-first/Public.js +0 -15
  240. package/dist/src/local-first/PublicKysely.d.ts +0 -148
  241. package/dist/src/local-first/PublicKysely.d.ts.map +0 -1
  242. package/dist/src/local-first/PublicKysely.js +0 -184
  243. package/dist/src/local-first/Sync.d.ts +0 -112
  244. package/dist/src/local-first/Sync.d.ts.map +0 -1
  245. package/dist/src/local-first/Sync.js +0 -526
  246. package/src/Instances.ts +0 -92
  247. package/src/Resources.ts +0 -367
  248. package/src/local-first/Platform.ts +0 -27
  249. package/src/local-first/Public.ts +0 -42
  250. package/src/local-first/PublicKysely.ts +0 -239
  251. package/src/local-first/Sync.ts +0 -949
@@ -1,8 +1,67 @@
1
1
  /**
2
- * Array types, type guards, operations, transformations, accessors, and (rare)
3
- * mutations
2
+ * Array helpers that help TypeScript help you.
4
3
  *
5
- * ### Example
4
+ * - **Non-empty arrays**: compile-time guarantee of at least one element
5
+ * - **Readonly arrays**: prevents accidental mutation
6
+ *
7
+ * Instead of checking array length at runtime, use {@link NonEmptyReadonlyArray}
8
+ * so TypeScript rejects empty arrays at compile time. Functions like
9
+ * {@link firstInArray} require a non-empty array — TypeScript won't let us pass
10
+ * an empty one. {@link mapArray} preserves non-emptiness (native `map` doesn't),
11
+ * while {@link appendToArray} and {@link prependToArray} guarantee the result is
12
+ * non-empty.
13
+ *
14
+ * All helpers return readonly arrays for safety. Consider how dangerous native
15
+ * `sort()` is — it mutates the original array and returns it, making bugs hard
16
+ * to track:
17
+ *
18
+ * ```ts
19
+ * const sortScores = (arr: number[]) => arr.sort((a, b) => a - b);
20
+ *
21
+ * const scores = [3, 1, 2];
22
+ * const leaderboard = sortScores(scores);
23
+ * leaderboard; // [1, 2, 3]
24
+ * scores; // [1, 2, 3] — original order lost!
25
+ * ```
26
+ *
27
+ * Imagine every method doing that.
28
+ *
29
+ * On a `ReadonlyArray`, `.sort()` doesn't even exist. Use {@link sortArray}
30
+ * instead:
31
+ *
32
+ * ```ts
33
+ * const sortScores = (arr: ReadonlyArray<number>) =>
34
+ * sortArray(arr, (a, b) => a - b);
35
+ *
36
+ * const scores: ReadonlyArray<number> = [3, 1, 2];
37
+ * const leaderboard = sortScores(scores);
38
+ * leaderboard; // [1, 2, 3]
39
+ * scores; // [3, 1, 2] — safe!
40
+ * ```
41
+ *
42
+ * Even better, require a {@link NonEmptyReadonlyArray} — there's nothing to sort
43
+ * if the array is empty anyway:
44
+ *
45
+ * ```ts
46
+ * const sortScores = (arr: NonEmptyReadonlyArray<number>) =>
47
+ * sortArray(arr, (a, b) => a - b);
48
+ * ```
49
+ *
50
+ * Sorting an empty array isn't expensive, but functions can have side effects
51
+ * like database queries or network requests. Using non-empty arrays whenever
52
+ * possible is a good convention.
53
+ *
54
+ * For performance-critical cases where mutation is needed, Evolu provides
55
+ * {@link shiftFromArray} and {@link popFromArray} — but only because they improve
56
+ * type safety by returning a guaranteed `T` rather than an optional value.
57
+ *
58
+ * ### When to use native methods
59
+ *
60
+ * These helpers only exist where they add type-level value. Native methods like
61
+ * `find`, `some`, `every`, `includes`, `indexOf`, and `findIndex` work well on
62
+ * readonly arrays without mutation — use them directly.
63
+ *
64
+ * ## Examples
6
65
  *
7
66
  * ```ts
8
67
  * // Types - compile-time guarantee of at least one element
@@ -12,15 +71,13 @@
12
71
  *
13
72
  * // Type guards
14
73
  * const arr: ReadonlyArray<number> = [1, 2, 3];
15
- * if (isNonEmptyReadonlyArray(arr)) {
74
+ * if (isNonEmptyArray(arr)) {
16
75
  * firstInArray(arr);
17
76
  * }
18
77
  *
19
- * // Operations
78
+ * // Transformations
20
79
  * const appended = appendToArray([1, 2, 3], 4); // [1, 2, 3, 4]
21
80
  * const prepended = prependToArray([2, 3], 1); // [1, 2, 3]
22
- *
23
- * // Transformations
24
81
  * const readonly: ReadonlyArray<number> = [1, 2, 3];
25
82
  * const mapped = mapArray(readonly, (x) => x * 2); // [2, 4, 6]
26
83
  * const filtered = filterArray(readonly, (x) => x > 1); // [2, 3]
@@ -28,7 +85,7 @@
28
85
  * const [evens, odds] = partitionArray(
29
86
  * [1, 2, 3, 4, 5],
30
87
  * (x) => x % 2 === 0,
31
- * ); // [[2, 4], [1, 3, 5]]
88
+ * );
32
89
  *
33
90
  * // Accessors
34
91
  * const first = firstInArray(["a", "b", "c"]); // "a"
@@ -36,131 +93,170 @@
36
93
  *
37
94
  * // Mutations
38
95
  * const mutable: NonEmptyArray<number> = [1, 2, 3];
39
- * shiftArray(mutable); // 1 (guaranteed to exist)
96
+ * shiftFromArray(mutable); // 1 (guaranteed to exist)
40
97
  * mutable; // [2, 3]
41
98
  * ```
42
99
  *
43
- * Functions are intentionally data-first to be prepared for the upcoming
44
- * JavaScript pipe operator.
100
+ * ## Composition
101
+ *
102
+ * All array helpers use a data-first style (the array is the first argument)
103
+ * because it's natural for single operations:
45
104
  *
46
105
  * ```ts
47
- * // Data-first is natural for single operations.
48
106
  * const timestamps = mapArray(messages, (m) => m.timestamp);
107
+ * ```
49
108
  *
50
- * // But data-first can be hard to read for nested calls.
51
- * const result = firstInArray(
52
- * mapArray(dedupeArray(appendToArray(value, 2)), (x) => x * 2),
53
- * );
109
+ * Data-first style also reads well for a few operations, often fitting on a
110
+ * line:
54
111
  *
55
- * // With the upcoming pipe operator, it's clear.
56
- * // const result = value
57
- * // |> appendToArray(%, 2)
58
- * // |> dedupeArray(%)
59
- * // |> mapArray(%, (x) => x * 2)
60
- * // |> firstInArray(%);
61
- *
62
- * // Until the pipe operator lands, use nested calls or name each step:
63
- * const appended = appendToArray(value, 2);
64
- * const deduped = dedupeArray(appended);
65
- * const mapped = mapArray(deduped, (x) => x * 2);
66
- * const result = firstInArray(mapped);
112
+ * ```ts
113
+ * const cheapest = firstInArray(sortArray(prices, orderNumber));
114
+ * const uniqueNames = dedupeArray(mapArray(users, (u) => u.name));
115
+ * const latestDone = lastInArray(filterArray(jobs, isCompletedJob));
67
116
  * ```
68
117
  *
69
- * ### Why data-first?
118
+ * For more operations, create a function like `getOldestActiveUser` or a
119
+ * generic helper.
70
120
  *
71
- * Evolu optimizes for consistent code style. We can't have both data-first
72
- * single operations and curried data-last helpers without sacrificing
73
- * consistency. We chose data-first because:
121
+ * Some libraries provide dual APIs with data-last for pipe-based composition.
122
+ * Evolu prefers simplicity (in Latin, simplex means "one") so we don't have to
123
+ * choose between seemingly equivalent options (Buridan's ass dilemma).
74
124
  *
75
- * - It's natural for single operations (for example `mapArray(messages, (m) =>
76
- * m.timestamp)`).
77
- * - It aligns with the upcoming JavaScript pipe operator.
78
- *
79
- * **Note**: Feel free to use Array instance methods (mutation) if you think
80
- * it's better (performance, local scope, etc.).
125
+ * Evolu doesn't provide `pipe` because few operations compose well without it,
126
+ * and for more operations, well-named functions communicate intent better.
81
127
  *
82
128
  * @module
83
129
  */
84
- import { PredicateWithIndex, RefinementWithIndex } from "./Types.js";
130
+ import type { PredicateWithIndex, RefinementWithIndex } from "./Types.js";
85
131
  /**
86
132
  * An array with at least one element.
87
133
  *
88
- * @category Types
134
+ * @group Types
89
135
  */
90
136
  export type NonEmptyArray<T> = [T, ...Array<T>];
91
137
  /**
92
138
  * A readonly array with at least one element.
93
139
  *
94
- * @category Types
140
+ * @group Types
95
141
  */
96
142
  export type NonEmptyReadonlyArray<T> = readonly [T, ...ReadonlyArray<T>];
97
143
  /**
98
- * Checks if an array is non-empty and narrows its type to {@link NonEmptyArray}.
144
+ * An empty readonly array.
99
145
  *
100
- * Use `if (!isNonEmptyArray(arr))` for empty checks.
146
+ * Use as a default or initial value to avoid allocating new empty arrays.
147
+ *
148
+ * @group Constants
149
+ */
150
+ export declare const emptyArray: ReadonlyArray<never>;
151
+ /**
152
+ * Better `Array.from`.
153
+ *
154
+ * - Returns readonly arrays
155
+ * - Accepts length directly: `arrayFrom(3, fn)` instead of `Array.from({ length:
156
+ * 3 }, fn)`
157
+ * - Skips copying if iterable is already an array (safe because readonly)
101
158
  *
102
159
  * ### Example
103
160
  *
104
161
  * ```ts
105
- * const arr: Array<number> = [1, 2, 3];
106
- * if (isNonEmptyArray(arr)) {
107
- * firstInArray(arr); // arr is NonEmptyArray<number>
108
- * }
162
+ * arrayFrom(new Set([1, 2, 3])); // ReadonlyArray<number>
163
+ * arrayFrom(3, (i) => i * 10); // [0, 10, 20]
164
+ * arrayFrom(iterableMaybeArray); // no unnecessary copy
109
165
  * ```
110
166
  *
111
- * @category Type Guards
167
+ * Unlike `Array.from`, there's no map parameter for iterables — use
168
+ * {@link mapArray} instead, or
169
+ * {@link https://web.dev/blog/baseline-iterator-helpers | iterator helpers}
170
+ * directly on iterables.
171
+ *
172
+ * @group Constructors
112
173
  */
113
- export declare const isNonEmptyArray: <T>(array: Array<T>) => array is NonEmptyArray<T>;
174
+ export declare function arrayFrom<T>(iterable: Iterable<T>): ReadonlyArray<T>;
175
+ /** From length and map function. */
176
+ export declare function arrayFrom<T>(length: number, map: (index: number) => T): ReadonlyArray<T>;
114
177
  /**
115
- * Checks if a readonly array is non-empty and narrows its type to
116
- * {@link NonEmptyReadonlyArray}.
178
+ * Better `Array.fromAsync`.
117
179
  *
118
- * Use `if (!isNonEmptyReadonlyArray(arr))` for empty checks.
180
+ * Returns a readonly array and awaits promised items from sync or async
181
+ * iterables.
119
182
  *
120
183
  * ### Example
121
184
  *
122
185
  * ```ts
123
- * const arr: ReadonlyArray<number> = [1, 2, 3];
124
- * if (isNonEmptyReadonlyArray(arr)) {
125
- * firstInArray(arr); // arr is NonEmptyReadonlyArray<number>
186
+ * await arrayFromAsync(new Set([1, 2, 3])); // ReadonlyArray<number>
187
+ * await arrayFromAsync(
188
+ * (async function* () {
189
+ * yield Promise.resolve(1);
190
+ * yield Promise.resolve(2);
191
+ * })(),
192
+ * ); // [1, 2]
193
+ * ```
194
+ *
195
+ * Unlike `Array.fromAsync`, there's no map parameter — map the result with
196
+ * {@link mapArray} or use
197
+ * {@link https://web.dev/blog/baseline-iterator-helpers | iterator helpers}
198
+ * directly on iterables.
199
+ *
200
+ * @group Constructors
201
+ */
202
+ export declare const arrayFromAsync: <T>(iterable: AsyncIterable<T> | Iterable<T | PromiseLike<T>>) => Promise<ReadonlyArray<T>>;
203
+ /**
204
+ * Checks if an array is non-empty and narrows its type to {@link NonEmptyArray}
205
+ * or {@link NonEmptyReadonlyArray} based on the input.
206
+ *
207
+ * To check if an array is empty, use `if (!isNonEmptyArray(arr))` — using the
208
+ * negated guard is better than `.length === 0` for early returns because
209
+ * TypeScript narrows the type after the check.
210
+ *
211
+ * ### Example
212
+ *
213
+ * ```ts
214
+ * // Mutable array narrows to NonEmptyArray
215
+ * const arr: Array<number> = [1, 2, 3];
216
+ * if (isNonEmptyArray(arr)) {
217
+ * shiftFromArray(arr); // arr is NonEmptyArray<number>
218
+ * }
219
+ *
220
+ * // Readonly array narrows to NonEmptyReadonlyArray
221
+ * const readonly: ReadonlyArray<number> = [1, 2, 3];
222
+ * if (isNonEmptyArray(readonly)) {
223
+ * firstInArray(readonly); // readonly is NonEmptyReadonlyArray<number>
126
224
  * }
127
225
  * ```
128
226
  *
129
- * @category Type Guards
227
+ * @group Types
130
228
  */
131
- export declare const isNonEmptyReadonlyArray: <T>(array: ReadonlyArray<T>) => array is NonEmptyReadonlyArray<T>;
229
+ export declare function isNonEmptyArray<T>(array: Array<T>): array is NonEmptyArray<T>;
230
+ /** Readonly array overload. */
231
+ export declare function isNonEmptyArray<T>(array: ReadonlyArray<T>): array is NonEmptyReadonlyArray<T>;
132
232
  /**
133
233
  * Appends an item to an array, returning a new non-empty readonly array.
134
234
  *
135
- * Accepts both mutable and readonly arrays. Does not mutate the original array.
136
- *
137
235
  * ### Example
138
236
  *
139
237
  * ```ts
140
238
  * appendToArray([1, 2, 3], 4); // [1, 2, 3, 4]
141
239
  * ```
142
240
  *
143
- * @category Operations
241
+ * @group Transformations
144
242
  */
145
243
  export declare const appendToArray: <T>(array: ReadonlyArray<T>, item: T) => NonEmptyReadonlyArray<T>;
146
244
  /**
147
245
  * Prepends an item to an array, returning a new non-empty readonly array.
148
246
  *
149
- * Accepts both mutable and readonly arrays. Does not mutate the original array.
150
- *
151
247
  * ### Example
152
248
  *
153
249
  * ```ts
154
250
  * prependToArray([2, 3], 1); // [1, 2, 3]
155
251
  * ```
156
252
  *
157
- * @category Operations
253
+ * @group Transformations
158
254
  */
159
255
  export declare const prependToArray: <T>(array: ReadonlyArray<T>, item: T) => NonEmptyReadonlyArray<T>;
160
256
  /**
161
- * Maps an array using a mapper function.
257
+ * Maps an array using a mapper function, returning a new readonly array.
162
258
  *
163
- * Accepts both mutable and readonly arrays. Preserves non-empty type.
259
+ * Preserves non-empty type.
164
260
  *
165
261
  * ### Example
166
262
  *
@@ -168,28 +264,86 @@ export declare const prependToArray: <T>(array: ReadonlyArray<T>, item: T) => No
168
264
  * mapArray([1, 2, 3], (x) => x * 2); // [2, 4, 6]
169
265
  * ```
170
266
  *
171
- * @category Transformations
267
+ * @group Transformations
172
268
  */
173
269
  export declare function mapArray<T, U>(array: NonEmptyReadonlyArray<T> | NonEmptyArray<T>, mapper: (item: T, index: number) => U): NonEmptyReadonlyArray<U>;
270
+ /** Possibly empty array. */
174
271
  export declare function mapArray<T, U>(array: ReadonlyArray<T> | Array<T>, mapper: (item: T, index: number) => U): ReadonlyArray<U>;
272
+ /**
273
+ * Maps each element to an array and flattens the result.
274
+ *
275
+ * Preserves non-empty type when the input is non-empty and the mapper returns
276
+ * non-empty arrays. When called without a mapper, flattens nested arrays using
277
+ * {@link identity}.
278
+ *
279
+ * ### Example
280
+ *
281
+ * ```ts
282
+ * flatMapArray([
283
+ * [1, 2],
284
+ * [3, 4],
285
+ * ]); // [1, 2, 3, 4]
286
+ *
287
+ * flatMapArray([1, 2, 3], (x) => [x, x * 10]); // [1, 10, 2, 20, 3, 30]
288
+ * ```
289
+ *
290
+ * ### Filter and map in one pass
291
+ *
292
+ * Return `[]` to filter out, `[value]` to keep:
293
+ *
294
+ * ```ts
295
+ * const errors = flatMapArray(fields, (f) => {
296
+ * const result = validate(f);
297
+ * return result.ok ? [] : [result.error];
298
+ * });
299
+ * ```
300
+ *
301
+ * @group Transformations
302
+ */
303
+ export declare function flatMapArray<T>(array: NonEmptyReadonlyArray<NonEmptyReadonlyArray<T> | NonEmptyArray<T>> | NonEmptyArray<NonEmptyReadonlyArray<T> | NonEmptyArray<T>>): NonEmptyReadonlyArray<T>;
304
+ /** Possibly empty nested arrays. */
305
+ export declare function flatMapArray<T>(array: ReadonlyArray<ReadonlyArray<T> | Array<T>> | Array<ReadonlyArray<T> | Array<T>>): ReadonlyArray<T>;
306
+ /** Non-empty with mapper returning non-empty. */
307
+ export declare function flatMapArray<T, U>(array: NonEmptyReadonlyArray<T> | NonEmptyArray<T>, mapper: (item: T, index: number) => NonEmptyReadonlyArray<U> | NonEmptyArray<U>): NonEmptyReadonlyArray<U>;
308
+ /** With mapper function. */
309
+ export declare function flatMapArray<T, U>(array: ReadonlyArray<T> | Array<T>, mapper: (item: T, index: number) => ReadonlyArray<U> | Array<U>): ReadonlyArray<U>;
310
+ /**
311
+ * Concatenates two arrays, returning a new readonly array.
312
+ *
313
+ * Returns a non-empty array when at least one input is non-empty.
314
+ *
315
+ * ### Example
316
+ *
317
+ * ```ts
318
+ * concatArrays([1, 2], [3, 4]); // [1, 2, 3, 4]
319
+ * concatArrays([], [1]); // [1] (non-empty)
320
+ * concatArrays([1], []); // [1] (non-empty)
321
+ * ```
322
+ *
323
+ * @group Transformations
324
+ */
325
+ export declare function concatArrays<T>(first: NonEmptyReadonlyArray<T> | NonEmptyArray<T>, second: ReadonlyArray<T> | Array<T>): NonEmptyReadonlyArray<T>;
326
+ /** Second non-empty. */
327
+ export declare function concatArrays<T>(first: ReadonlyArray<T> | Array<T>, second: NonEmptyReadonlyArray<T> | NonEmptyArray<T>): NonEmptyReadonlyArray<T>;
328
+ /** Both possibly empty. */
329
+ export declare function concatArrays<T>(first: ReadonlyArray<T> | Array<T>, second: ReadonlyArray<T> | Array<T>): ReadonlyArray<T>;
175
330
  /**
176
331
  * Filters an array using a predicate or refinement function, returning a new
177
332
  * readonly array.
178
333
  *
179
- * Accepts both mutable and readonly arrays. When used with a refinement
180
- * function (with `value is Type` syntax), TypeScript will narrow the result
181
- * type to the narrowed type, making it useful for filtering with Evolu Types
182
- * like `PositiveInt.is`.
334
+ * When used with a refinement function (with `value is Type` syntax),
335
+ * TypeScript will narrow the result type to the narrowed type, making it useful
336
+ * for filtering with Evolu Types like `PositiveInt.is`.
183
337
  *
184
- * ### Examples
338
+ * ### Example
185
339
  *
186
- * #### With predicate
340
+ * ### With predicate
187
341
  *
188
342
  * ```ts
189
343
  * filterArray([1, 2, 3, 4, 5], (x) => x % 2 === 0); // [2, 4]
190
344
  * ```
191
345
  *
192
- * #### With refinement
346
+ * ### With refinement
193
347
  *
194
348
  * ```ts
195
349
  * const mixed: ReadonlyArray<NonEmptyString | PositiveInt> = [
@@ -200,9 +354,10 @@ export declare function mapArray<T, U>(array: ReadonlyArray<T> | Array<T>, mappe
200
354
  * // positiveInts: ReadonlyArray<PositiveInt> (narrowed type)
201
355
  * ```
202
356
  *
203
- * @category Transformations
357
+ * @group Transformations
204
358
  */
205
359
  export declare function filterArray<T, S extends T>(array: ReadonlyArray<T>, refinement: RefinementWithIndex<T, S>): ReadonlyArray<S>;
360
+ /** With predicate. */
206
361
  export declare function filterArray<T>(array: ReadonlyArray<T>, predicate: PredicateWithIndex<T>): ReadonlyArray<T>;
207
362
  /**
208
363
  * Returns a new readonly array with duplicate items removed. If `by` is
@@ -210,7 +365,6 @@ export declare function filterArray<T>(array: ReadonlyArray<T>, predicate: Predi
210
365
  * are used directly. Dedupes by reference equality of values (or extracted keys
211
366
  * when `by` is used).
212
367
  *
213
- * Accepts both mutable and readonly arrays. Does not mutate the original array.
214
368
  * Preserves non-empty type.
215
369
  *
216
370
  * ### Example
@@ -230,25 +384,25 @@ export declare function filterArray<T>(array: ReadonlyArray<T>, predicate: Predi
230
384
  * ); // [{ id: 1, name: "Alice" }, { id: 2, name: "Bob" }]
231
385
  * ```
232
386
  *
233
- * @category Transformations
387
+ * @group Transformations
234
388
  */
235
389
  export declare function dedupeArray<T>(array: NonEmptyReadonlyArray<T> | NonEmptyArray<T>, by?: (item: T) => unknown): NonEmptyReadonlyArray<T>;
390
+ /** Possibly empty array. */
236
391
  export declare function dedupeArray<T>(array: ReadonlyArray<T> | Array<T>, by?: (item: T) => unknown): ReadonlyArray<T>;
237
392
  /**
238
- * Partitions an array into two arrays based on a predicate or refinement
239
- * function.
393
+ * Partitions an array into two readonly arrays based on a predicate or
394
+ * refinement function.
240
395
  *
241
396
  * Returns a tuple where the first array contains elements that satisfy the
242
- * predicate, and the second array contains elements that do not. Accepts both
243
- * mutable and readonly arrays.
397
+ * predicate, and the second array contains elements that do not.
244
398
  *
245
399
  * When used with a refinement function (with `value is Type` syntax),
246
400
  * TypeScript will narrow the first array to the narrowed type, making it useful
247
401
  * for filtering with Evolu Types like `PositiveInt.is`.
248
402
  *
249
- * ### Examples
403
+ * ### Example
250
404
  *
251
- * #### With predicate
405
+ * ### With predicate
252
406
  *
253
407
  * ```ts
254
408
  * const [evens, odds] = partitionArray(
@@ -259,7 +413,7 @@ export declare function dedupeArray<T>(array: ReadonlyArray<T> | Array<T>, by?:
259
413
  * odds; // [1, 3, 5]
260
414
  * ```
261
415
  *
262
- * #### With refinement
416
+ * ### With refinement
263
417
  *
264
418
  * ```ts
265
419
  * const mixed: ReadonlyArray<NonEmptyString | PositiveInt> = [
@@ -271,14 +425,98 @@ export declare function dedupeArray<T>(array: ReadonlyArray<T> | Array<T>, by?:
271
425
  * // strings: ReadonlyArray<NonEmptyString> (Exclude<T, PositiveInt>)
272
426
  * ```
273
427
  *
274
- * @category Transformations
428
+ * @group Transformations
275
429
  */
276
430
  export declare function partitionArray<T, S extends T>(array: ReadonlyArray<T>, refinement: RefinementWithIndex<T, S>): readonly [ReadonlyArray<S>, ReadonlyArray<Exclude<T, S>>];
431
+ /** With predicate. */
277
432
  export declare function partitionArray<T>(array: ReadonlyArray<T>, predicate: PredicateWithIndex<T>): readonly [ReadonlyArray<T>, ReadonlyArray<T>];
278
433
  /**
279
- * Returns the first element of a non-empty array.
434
+ * Returns a new sorted readonly array.
435
+ *
436
+ * Wraps native `toSorted`. Preserves non-empty type.
437
+ *
438
+ * ### Example
439
+ *
440
+ * ```ts
441
+ * sortArray([3, 1, 2], (a, b) => a - b); // [1, 2, 3]
442
+ * ```
280
443
  *
281
- * Accepts both mutable and readonly arrays. Does not mutate the original array.
444
+ * @group Transformations
445
+ */
446
+ export declare function sortArray<T>(array: NonEmptyReadonlyArray<T>, compareFn?: (a: T, b: T) => number): NonEmptyReadonlyArray<T>;
447
+ /** Possibly empty array. */
448
+ export declare function sortArray<T>(array: ReadonlyArray<T>, compareFn?: (a: T, b: T) => number): ReadonlyArray<T>;
449
+ /**
450
+ * Returns a new reversed readonly array.
451
+ *
452
+ * Wraps native `toReversed`. Preserves non-empty type.
453
+ *
454
+ * ### Example
455
+ *
456
+ * ```ts
457
+ * reverseArray([1, 2, 3]); // [3, 2, 1]
458
+ * ```
459
+ *
460
+ * @group Transformations
461
+ */
462
+ export declare function reverseArray<T>(array: NonEmptyReadonlyArray<T>): NonEmptyReadonlyArray<T>;
463
+ /** Possibly empty array. */
464
+ export declare function reverseArray<T>(array: ReadonlyArray<T>): ReadonlyArray<T>;
465
+ /**
466
+ * Returns a new readonly array with elements removed and/or replaced.
467
+ *
468
+ * Wraps native `toSpliced`.
469
+ *
470
+ * ### Example
471
+ *
472
+ * ```ts
473
+ * spliceArray([1, 2, 3, 4], 1, 2); // [1, 4]
474
+ * spliceArray([1, 2, 3], 1, 1, 10, 11); // [1, 10, 11, 3]
475
+ * ```
476
+ *
477
+ * @group Transformations
478
+ */
479
+ export declare const spliceArray: <T>(array: ReadonlyArray<T>, start: number, deleteCount: number, ...items: ReadonlyArray<T>) => ReadonlyArray<T>;
480
+ /**
481
+ * Extracts element types from a tuple of arrays, producing a tuple type.
482
+ *
483
+ * @group Types
484
+ */
485
+ export type ZipArrayResult<T extends ReadonlyArray<ReadonlyArray<unknown>>> = {
486
+ [K in keyof T]: T[K] extends ReadonlyArray<infer U> ? U : never;
487
+ };
488
+ /**
489
+ * Combines multiple arrays into an array of tuples.
490
+ *
491
+ * Uses "shortest" mode — stops at the shortest input array. Preserves non-empty
492
+ * type when all input arrays are non-empty. See the
493
+ * {@link https://github.com/tc39/proposal-array-zip | TC39 Array.zip proposal}
494
+ * for the pattern this follows.
495
+ *
496
+ * ### Example
497
+ *
498
+ * ```ts
499
+ * zipArray([
500
+ * [1, 2, 3],
501
+ * ["a", "b", "c"],
502
+ * ]);
503
+ * // [[1, "a"], [2, "b"], [3, "c"]]
504
+ *
505
+ * zipArray([
506
+ * [1, 2],
507
+ * ["a", "b", "c"],
508
+ * [true, false],
509
+ * ]);
510
+ * // [[1, "a", true], [2, "b", false]]
511
+ * ```
512
+ *
513
+ * @group Transformations
514
+ */
515
+ export declare function zipArray<T extends NonEmptyReadonlyArray<NonEmptyReadonlyArray<unknown>>>(arrays: T): NonEmptyReadonlyArray<Readonly<ZipArrayResult<T>>>;
516
+ /** Possibly empty arrays. */
517
+ export declare function zipArray<T extends ReadonlyArray<ReadonlyArray<unknown>>>(arrays: T): ReadonlyArray<Readonly<ZipArrayResult<T>>>;
518
+ /**
519
+ * Returns the first element of a non-empty array.
282
520
  *
283
521
  * ### Example
284
522
  *
@@ -286,53 +524,56 @@ export declare function partitionArray<T>(array: ReadonlyArray<T>, predicate: Pr
286
524
  * firstInArray(["a", "b", "c"]); // "a"
287
525
  * ```
288
526
  *
289
- * @category Accessors
527
+ * @group Accessors
290
528
  */
291
529
  export declare const firstInArray: <T>(array: NonEmptyReadonlyArray<T>) => T;
292
530
  /**
293
531
  * Returns the last element of a non-empty array.
294
532
  *
295
- * Accepts both mutable and readonly arrays. Does not mutate the original array.
296
- *
297
533
  * ### Example
298
534
  *
299
535
  * ```ts
300
536
  * lastInArray(["a", "b", "c"]); // "c"
301
537
  * ```
302
538
  *
303
- * @category Accessors
539
+ * @group Accessors
304
540
  */
305
541
  export declare const lastInArray: <T>(array: NonEmptyReadonlyArray<T>) => T;
306
542
  /**
307
- * Shifts an item from a non-empty mutable array, guaranteed to return T.
543
+ * Shifts (removes and returns) the first element from a non-empty mutable
544
+ * array.
308
545
  *
309
546
  * **Mutates** the original array.
310
547
  *
311
548
  * ### Example
312
549
  *
313
550
  * ```ts
314
- * const arr: NonEmptyArray<number> = [1, 2, 3];
315
- * shiftArray(arr); // 1
316
- * arr; // [2, 3]
551
+ * // Process a queue of callbacks
552
+ * const waitingQueue: Array<() => void> = [callback1, callback2];
553
+ * if (isNonEmptyArray(waitingQueue)) {
554
+ * shiftFromArray(waitingQueue)(); // Remove and immediately invoke
555
+ * }
317
556
  * ```
318
557
  *
319
- * @category Mutations
558
+ * @group Mutations
320
559
  */
321
- export declare const shiftArray: <T>(array: NonEmptyArray<T>) => T;
560
+ export declare const shiftFromArray: <T>(array: NonEmptyArray<T>) => T;
322
561
  /**
323
- * Pops an item from a non-empty mutable array, guaranteed to return T.
562
+ * Pops (removes and returns) the last element from a non-empty mutable array.
324
563
  *
325
564
  * **Mutates** the original array.
326
565
  *
327
566
  * ### Example
328
567
  *
329
568
  * ```ts
330
- * const arr: NonEmptyArray<number> = [1, 2, 3];
331
- * popArray(arr); // 3
332
- * arr; // [1, 2]
569
+ * // Process a stack of callbacks (LIFO)
570
+ * const callbackStack: Array<() => void> = [callback1, callback2];
571
+ * if (isNonEmptyArray(callbackStack)) {
572
+ * popFromArray(callbackStack)(); // Remove and immediately invoke
573
+ * }
333
574
  * ```
334
575
  *
335
- * @category Mutations
576
+ * @group Mutations
336
577
  */
337
- export declare const popArray: <T>(array: NonEmptyArray<T>) => T;
578
+ export declare const popFromArray: <T>(array: NonEmptyArray<T>) => T;
338
579
  //# sourceMappingURL=Array.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Array.d.ts","sourceRoot":"","sources":["../../src/Array.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AAEH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,KACd,KAAK,IAAI,aAAa,CAAC,CAAC,CAAqB,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GA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