@nlozgachev/pipelined 0.12.0 → 0.14.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 (213) hide show
  1. package/LICENCE +28 -0
  2. package/README.md +1 -1
  3. package/{types/src/Types/NonEmptyList.d.ts → dist/NonEmptyList-BlGFjor5.d.mts} +4 -3
  4. package/dist/NonEmptyList-BlGFjor5.d.ts +30 -0
  5. package/dist/Task-Bd3gXPRQ.d.mts +677 -0
  6. package/dist/Task-BjAkkD6t.d.ts +677 -0
  7. package/dist/chunk-4TXC322E.mjs +136 -0
  8. package/dist/chunk-BYWKZLHM.mjs +10 -0
  9. package/dist/chunk-DBIC62UV.mjs +6 -0
  10. package/dist/chunk-FAZN3IWZ.mjs +554 -0
  11. package/dist/chunk-QPTGO5AS.mjs +150 -0
  12. package/dist/chunk-UV2HMF2A.mjs +514 -0
  13. package/dist/composition.d.mts +495 -0
  14. package/dist/composition.d.ts +495 -0
  15. package/dist/composition.js +188 -0
  16. package/dist/composition.mjs +58 -0
  17. package/dist/core.d.mts +2170 -0
  18. package/dist/core.d.ts +2170 -0
  19. package/dist/core.js +698 -0
  20. package/dist/core.mjs +42 -0
  21. package/dist/index.d.mts +6 -0
  22. package/dist/index.d.ts +6 -0
  23. package/dist/index.js +1421 -0
  24. package/dist/index.mjs +120 -0
  25. package/dist/types.d.mts +54 -0
  26. package/{types/src/Types/Brand.d.ts → dist/types.d.ts} +6 -4
  27. package/dist/types.js +41 -0
  28. package/dist/types.mjs +10 -0
  29. package/dist/utils.d.mts +1285 -0
  30. package/dist/utils.d.ts +1285 -0
  31. package/dist/utils.js +722 -0
  32. package/dist/utils.mjs +18 -0
  33. package/package.json +64 -69
  34. package/esm/mod.js +0 -3
  35. package/esm/package.json +0 -3
  36. package/esm/src/Composition/compose.js +0 -3
  37. package/esm/src/Composition/converge.js +0 -3
  38. package/esm/src/Composition/curry.js +0 -42
  39. package/esm/src/Composition/flip.js +0 -20
  40. package/esm/src/Composition/flow.js +0 -8
  41. package/esm/src/Composition/fn.js +0 -85
  42. package/esm/src/Composition/index.js +0 -13
  43. package/esm/src/Composition/juxt.js +0 -3
  44. package/esm/src/Composition/memoize.js +0 -66
  45. package/esm/src/Composition/not.js +0 -25
  46. package/esm/src/Composition/on.js +0 -12
  47. package/esm/src/Composition/pipe.js +0 -3
  48. package/esm/src/Composition/tap.js +0 -33
  49. package/esm/src/Composition/uncurry.js +0 -32
  50. package/esm/src/Core/Deferred.js +0 -30
  51. package/esm/src/Core/InternalTypes.js +0 -1
  52. package/esm/src/Core/Lens.js +0 -98
  53. package/esm/src/Core/Logged.js +0 -111
  54. package/esm/src/Core/Option.js +0 -191
  55. package/esm/src/Core/Optional.js +0 -160
  56. package/esm/src/Core/Predicate.js +0 -133
  57. package/esm/src/Core/Reader.js +0 -134
  58. package/esm/src/Core/Refinement.js +0 -115
  59. package/esm/src/Core/RemoteData.js +0 -211
  60. package/esm/src/Core/Result.js +0 -170
  61. package/esm/src/Core/State.js +0 -181
  62. package/esm/src/Core/Task.js +0 -223
  63. package/esm/src/Core/TaskOption.js +0 -106
  64. package/esm/src/Core/TaskResult.js +0 -127
  65. package/esm/src/Core/TaskValidation.js +0 -128
  66. package/esm/src/Core/These.js +0 -245
  67. package/esm/src/Core/Tuple.js +0 -112
  68. package/esm/src/Core/Validation.js +0 -212
  69. package/esm/src/Core/index.js +0 -18
  70. package/esm/src/Types/Brand.js +0 -28
  71. package/esm/src/Types/NonEmptyList.js +0 -14
  72. package/esm/src/Types/index.js +0 -2
  73. package/esm/src/Utils/Arr.js +0 -570
  74. package/esm/src/Utils/Dict.js +0 -421
  75. package/esm/src/Utils/Num.js +0 -124
  76. package/esm/src/Utils/Rec.js +0 -241
  77. package/esm/src/Utils/Str.js +0 -134
  78. package/esm/src/Utils/Uniq.js +0 -265
  79. package/esm/src/Utils/index.js +0 -6
  80. package/script/mod.js +0 -19
  81. package/script/package.json +0 -3
  82. package/script/src/Composition/compose.js +0 -6
  83. package/script/src/Composition/converge.js +0 -6
  84. package/script/src/Composition/curry.js +0 -48
  85. package/script/src/Composition/flip.js +0 -24
  86. package/script/src/Composition/flow.js +0 -11
  87. package/script/src/Composition/fn.js +0 -98
  88. package/script/src/Composition/index.js +0 -29
  89. package/script/src/Composition/juxt.js +0 -6
  90. package/script/src/Composition/memoize.js +0 -71
  91. package/script/src/Composition/not.js +0 -29
  92. package/script/src/Composition/on.js +0 -16
  93. package/script/src/Composition/pipe.js +0 -6
  94. package/script/src/Composition/tap.js +0 -37
  95. package/script/src/Composition/uncurry.js +0 -38
  96. package/script/src/Core/Deferred.js +0 -33
  97. package/script/src/Core/InternalTypes.js +0 -2
  98. package/script/src/Core/Lens.js +0 -101
  99. package/script/src/Core/Logged.js +0 -114
  100. package/script/src/Core/Option.js +0 -194
  101. package/script/src/Core/Optional.js +0 -163
  102. package/script/src/Core/Predicate.js +0 -136
  103. package/script/src/Core/Reader.js +0 -137
  104. package/script/src/Core/Refinement.js +0 -118
  105. package/script/src/Core/RemoteData.js +0 -214
  106. package/script/src/Core/Result.js +0 -173
  107. package/script/src/Core/State.js +0 -184
  108. package/script/src/Core/Task.js +0 -226
  109. package/script/src/Core/TaskOption.js +0 -109
  110. package/script/src/Core/TaskResult.js +0 -130
  111. package/script/src/Core/TaskValidation.js +0 -131
  112. package/script/src/Core/These.js +0 -248
  113. package/script/src/Core/Tuple.js +0 -115
  114. package/script/src/Core/Validation.js +0 -215
  115. package/script/src/Core/index.js +0 -34
  116. package/script/src/Types/Brand.js +0 -31
  117. package/script/src/Types/NonEmptyList.js +0 -18
  118. package/script/src/Types/index.js +0 -18
  119. package/script/src/Utils/Arr.js +0 -573
  120. package/script/src/Utils/Dict.js +0 -424
  121. package/script/src/Utils/Num.js +0 -127
  122. package/script/src/Utils/Rec.js +0 -244
  123. package/script/src/Utils/Str.js +0 -137
  124. package/script/src/Utils/Uniq.js +0 -268
  125. package/script/src/Utils/index.js +0 -22
  126. package/types/mod.d.ts +0 -4
  127. package/types/mod.d.ts.map +0 -1
  128. package/types/src/Composition/compose.d.ts +0 -33
  129. package/types/src/Composition/compose.d.ts.map +0 -1
  130. package/types/src/Composition/converge.d.ts +0 -21
  131. package/types/src/Composition/converge.d.ts.map +0 -1
  132. package/types/src/Composition/curry.d.ts +0 -43
  133. package/types/src/Composition/curry.d.ts.map +0 -1
  134. package/types/src/Composition/flip.d.ts +0 -21
  135. package/types/src/Composition/flip.d.ts.map +0 -1
  136. package/types/src/Composition/flow.d.ts +0 -56
  137. package/types/src/Composition/flow.d.ts.map +0 -1
  138. package/types/src/Composition/fn.d.ts +0 -76
  139. package/types/src/Composition/fn.d.ts.map +0 -1
  140. package/types/src/Composition/index.d.ts +0 -14
  141. package/types/src/Composition/index.d.ts.map +0 -1
  142. package/types/src/Composition/juxt.d.ts +0 -18
  143. package/types/src/Composition/juxt.d.ts.map +0 -1
  144. package/types/src/Composition/memoize.d.ts +0 -46
  145. package/types/src/Composition/memoize.d.ts.map +0 -1
  146. package/types/src/Composition/not.d.ts +0 -26
  147. package/types/src/Composition/not.d.ts.map +0 -1
  148. package/types/src/Composition/on.d.ts +0 -13
  149. package/types/src/Composition/on.d.ts.map +0 -1
  150. package/types/src/Composition/pipe.d.ts +0 -56
  151. package/types/src/Composition/pipe.d.ts.map +0 -1
  152. package/types/src/Composition/tap.d.ts +0 -31
  153. package/types/src/Composition/tap.d.ts.map +0 -1
  154. package/types/src/Composition/uncurry.d.ts +0 -54
  155. package/types/src/Composition/uncurry.d.ts.map +0 -1
  156. package/types/src/Core/Deferred.d.ts +0 -49
  157. package/types/src/Core/Deferred.d.ts.map +0 -1
  158. package/types/src/Core/InternalTypes.d.ts +0 -23
  159. package/types/src/Core/InternalTypes.d.ts.map +0 -1
  160. package/types/src/Core/Lens.d.ts +0 -118
  161. package/types/src/Core/Lens.d.ts.map +0 -1
  162. package/types/src/Core/Logged.d.ts +0 -126
  163. package/types/src/Core/Logged.d.ts.map +0 -1
  164. package/types/src/Core/Option.d.ts +0 -209
  165. package/types/src/Core/Option.d.ts.map +0 -1
  166. package/types/src/Core/Optional.d.ts +0 -158
  167. package/types/src/Core/Optional.d.ts.map +0 -1
  168. package/types/src/Core/Predicate.d.ts +0 -161
  169. package/types/src/Core/Predicate.d.ts.map +0 -1
  170. package/types/src/Core/Reader.d.ts +0 -156
  171. package/types/src/Core/Reader.d.ts.map +0 -1
  172. package/types/src/Core/Refinement.d.ts +0 -138
  173. package/types/src/Core/Refinement.d.ts.map +0 -1
  174. package/types/src/Core/RemoteData.d.ts +0 -197
  175. package/types/src/Core/RemoteData.d.ts.map +0 -1
  176. package/types/src/Core/Result.d.ts +0 -182
  177. package/types/src/Core/Result.d.ts.map +0 -1
  178. package/types/src/Core/State.d.ts +0 -192
  179. package/types/src/Core/State.d.ts.map +0 -1
  180. package/types/src/Core/Task.d.ts +0 -219
  181. package/types/src/Core/Task.d.ts.map +0 -1
  182. package/types/src/Core/TaskOption.d.ts +0 -121
  183. package/types/src/Core/TaskOption.d.ts.map +0 -1
  184. package/types/src/Core/TaskResult.d.ts +0 -119
  185. package/types/src/Core/TaskResult.d.ts.map +0 -1
  186. package/types/src/Core/TaskValidation.d.ts +0 -144
  187. package/types/src/Core/TaskValidation.d.ts.map +0 -1
  188. package/types/src/Core/These.d.ts +0 -225
  189. package/types/src/Core/These.d.ts.map +0 -1
  190. package/types/src/Core/Tuple.d.ts +0 -129
  191. package/types/src/Core/Tuple.d.ts.map +0 -1
  192. package/types/src/Core/Validation.d.ts +0 -203
  193. package/types/src/Core/Validation.d.ts.map +0 -1
  194. package/types/src/Core/index.d.ts +0 -19
  195. package/types/src/Core/index.d.ts.map +0 -1
  196. package/types/src/Types/Brand.d.ts.map +0 -1
  197. package/types/src/Types/NonEmptyList.d.ts.map +0 -1
  198. package/types/src/Types/index.d.ts +0 -3
  199. package/types/src/Types/index.d.ts.map +0 -1
  200. package/types/src/Utils/Arr.d.ts +0 -403
  201. package/types/src/Utils/Arr.d.ts.map +0 -1
  202. package/types/src/Utils/Dict.d.ts +0 -310
  203. package/types/src/Utils/Dict.d.ts.map +0 -1
  204. package/types/src/Utils/Num.d.ts +0 -110
  205. package/types/src/Utils/Num.d.ts.map +0 -1
  206. package/types/src/Utils/Rec.d.ts +0 -159
  207. package/types/src/Utils/Rec.d.ts.map +0 -1
  208. package/types/src/Utils/Str.d.ts +0 -128
  209. package/types/src/Utils/Str.d.ts.map +0 -1
  210. package/types/src/Utils/Uniq.d.ts +0 -179
  211. package/types/src/Utils/Uniq.d.ts.map +0 -1
  212. package/types/src/Utils/index.d.ts +0 -7
  213. package/types/src/Utils/index.d.ts.map +0 -1
@@ -1,310 +0,0 @@
1
- import { Option } from "../Core/Option.js";
2
- /**
3
- * Functional utilities for key-value dictionaries (`ReadonlyMap<K, V>`). All functions are pure
4
- * and data-last — they compose naturally with `pipe`.
5
- *
6
- * Unlike plain objects (`Rec`), dictionaries support any key type, preserve insertion order, and
7
- * make membership checks explicit via `lookup` returning `Option`.
8
- *
9
- * @example
10
- * ```ts
11
- * import { Dict } from "@nlozgachev/pipelined/utils";
12
- * import { pipe } from "@nlozgachev/pipelined/composition";
13
- *
14
- * const scores = pipe(
15
- * Dict.fromEntries([["alice", 10], ["bob", 8], ["carol", 10]] as const),
16
- * Dict.filter(n => n >= 10),
17
- * Dict.map(n => `${n} points`),
18
- * );
19
- * // ReadonlyMap { "alice" => "10 points", "carol" => "10 points" }
20
- * ```
21
- */
22
- export declare namespace Dict {
23
- /**
24
- * Creates an empty dictionary.
25
- *
26
- * @example
27
- * ```ts
28
- * Dict.empty<string, number>(); // ReadonlyMap {}
29
- * ```
30
- */
31
- const empty: <K, V>() => ReadonlyMap<K, V>;
32
- /**
33
- * Creates a dictionary with a single entry.
34
- *
35
- * @example
36
- * ```ts
37
- * Dict.singleton("name", "Alice"); // ReadonlyMap { "name" => "Alice" }
38
- * ```
39
- */
40
- const singleton: <K, V>(key: K, value: V) => ReadonlyMap<K, V>;
41
- /**
42
- * Creates a dictionary from an array of key-value pairs.
43
- *
44
- * @example
45
- * ```ts
46
- * Dict.fromEntries([["a", 1], ["b", 2]]); // ReadonlyMap { "a" => 1, "b" => 2 }
47
- * ```
48
- */
49
- const fromEntries: <K, V>(entries: readonly (readonly [K, V])[]) => ReadonlyMap<K, V>;
50
- /**
51
- * Creates a dictionary from a plain object. Keys are always strings.
52
- *
53
- * @example
54
- * ```ts
55
- * Dict.fromRecord({ a: 1, b: 2 }); // ReadonlyMap { "a" => 1, "b" => 2 }
56
- * ```
57
- */
58
- const fromRecord: <V>(rec: Readonly<Record<string, V>>) => ReadonlyMap<string, V>;
59
- /**
60
- * Groups elements of an array into a dictionary keyed by the result of `keyFn`. Each key maps
61
- * to the array of elements that produced it, in insertion order. Uses the native `Map.groupBy`
62
- * when available, falling back to a manual loop in older environments.
63
- *
64
- * @example
65
- * ```ts
66
- * pipe(
67
- * [{ name: "alice", role: "admin" }, { name: "bob", role: "viewer" }, { name: "carol", role: "admin" }],
68
- * Dict.groupBy(user => user.role),
69
- * );
70
- * // ReadonlyMap { "admin" => [alice, carol], "viewer" => [bob] }
71
- * ```
72
- */
73
- const groupBy: <K, A>(keyFn: (a: A) => K) => (items: readonly A[]) => ReadonlyMap<K, readonly A[]>;
74
- /**
75
- * Returns `true` if the dictionary contains the given key.
76
- *
77
- * @example
78
- * ```ts
79
- * pipe(Dict.fromEntries([["a", 1]]), Dict.has("a")); // true
80
- * pipe(Dict.fromEntries([["a", 1]]), Dict.has("b")); // false
81
- * ```
82
- */
83
- const has: <K>(key: K) => <V>(m: ReadonlyMap<K, V>) => boolean;
84
- /**
85
- * Looks up a value by key, returning `Some(value)` if found and `None` if not.
86
- *
87
- * @example
88
- * ```ts
89
- * pipe(Dict.fromEntries([["a", 1]]), Dict.lookup("a")); // Some(1)
90
- * pipe(Dict.fromEntries([["a", 1]]), Dict.lookup("b")); // None
91
- * ```
92
- */
93
- const lookup: <K>(key: K) => <V>(m: ReadonlyMap<K, V>) => Option<V>;
94
- /**
95
- * Returns the number of entries in the dictionary.
96
- *
97
- * @example
98
- * ```ts
99
- * Dict.size(Dict.fromEntries([["a", 1], ["b", 2]])); // 2
100
- * ```
101
- */
102
- const size: <K, V>(m: ReadonlyMap<K, V>) => number;
103
- /**
104
- * Returns `true` if the dictionary has no entries.
105
- *
106
- * @example
107
- * ```ts
108
- * Dict.isEmpty(Dict.empty()); // true
109
- * ```
110
- */
111
- const isEmpty: <K, V>(m: ReadonlyMap<K, V>) => boolean;
112
- /**
113
- * Returns all keys as a readonly array, in insertion order.
114
- *
115
- * @example
116
- * ```ts
117
- * Dict.keys(Dict.fromEntries([["a", 1], ["b", 2]])); // ["a", "b"]
118
- * ```
119
- */
120
- const keys: <K, V>(m: ReadonlyMap<K, V>) => readonly K[];
121
- /**
122
- * Returns all values as a readonly array, in insertion order.
123
- *
124
- * @example
125
- * ```ts
126
- * Dict.values(Dict.fromEntries([["a", 1], ["b", 2]])); // [1, 2]
127
- * ```
128
- */
129
- const values: <K, V>(m: ReadonlyMap<K, V>) => readonly V[];
130
- /**
131
- * Returns all key-value pairs as a readonly array of tuples, in insertion order.
132
- *
133
- * @example
134
- * ```ts
135
- * Dict.entries(Dict.fromEntries([["a", 1], ["b", 2]])); // [["a", 1], ["b", 2]]
136
- * ```
137
- */
138
- const entries: <K, V>(m: ReadonlyMap<K, V>) => readonly (readonly [K, V])[];
139
- /**
140
- * Returns a new dictionary with the given key set to the given value.
141
- * If the key already exists, its value is replaced.
142
- *
143
- * @example
144
- * ```ts
145
- * pipe(Dict.fromEntries([["a", 1]]), Dict.insert("b", 2));
146
- * // ReadonlyMap { "a" => 1, "b" => 2 }
147
- * ```
148
- */
149
- const insert: <K, V>(key: K, value: V) => (m: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
150
- /**
151
- * Returns a new dictionary with the given key removed.
152
- * If the key does not exist, the dictionary is returned unchanged.
153
- *
154
- * @example
155
- * ```ts
156
- * pipe(Dict.fromEntries([["a", 1], ["b", 2]]), Dict.remove("a"));
157
- * // ReadonlyMap { "b" => 2 }
158
- * ```
159
- */
160
- const remove: <K, V>(key: K) => (m: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
161
- /**
162
- * Returns a new dictionary with the value at `key` set by `f`. If the key does not exist,
163
- * `f` receives `None`. If the key exists, `f` receives `Some(currentValue)`.
164
- *
165
- * Useful for incrementing counters, initialising defaults, or conditional updates.
166
- *
167
- * @example
168
- * ```ts
169
- * import { Option } from "@nlozgachev/pipelined/core";
170
- *
171
- * const increment = (opt: Option<number>) => Option.getOrElse(() => 0)(opt) + 1;
172
- * pipe(Dict.fromEntries([["views", 5]]), Dict.upsert("views", increment)); // { views: 6 }
173
- * pipe(Dict.fromEntries([["views", 5]]), Dict.upsert("likes", increment)); // { views: 5, likes: 1 }
174
- * ```
175
- */
176
- const upsert: <K, V>(key: K, f: (existing: Option<V>) => V) => (m: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
177
- /**
178
- * Transforms each value in the dictionary.
179
- *
180
- * @example
181
- * ```ts
182
- * pipe(Dict.fromEntries([["a", 1], ["b", 2]]), Dict.map(n => n * 2));
183
- * // ReadonlyMap { "a" => 2, "b" => 4 }
184
- * ```
185
- */
186
- const map: <A, B>(f: (a: A) => B) => <K>(m: ReadonlyMap<K, A>) => ReadonlyMap<K, B>;
187
- /**
188
- * Transforms each value in the dictionary, also receiving the key.
189
- *
190
- * @example
191
- * ```ts
192
- * pipe(Dict.fromEntries([["a", 1], ["b", 2]]), Dict.mapWithKey((k, v) => `${k}:${v}`));
193
- * // ReadonlyMap { "a" => "a:1", "b" => "b:2" }
194
- * ```
195
- */
196
- const mapWithKey: <K, A, B>(f: (key: K, a: A) => B) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, B>;
197
- /**
198
- * Returns a new dictionary containing only the entries for which the predicate returns `true`.
199
- *
200
- * @example
201
- * ```ts
202
- * pipe(Dict.fromEntries([["a", 1], ["b", 3], ["c", 0]]), Dict.filter(n => n > 0));
203
- * // ReadonlyMap { "a" => 1, "b" => 3 }
204
- * ```
205
- */
206
- const filter: <A>(predicate: (a: A) => boolean) => <K>(m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>;
207
- /**
208
- * Returns a new dictionary containing only the entries for which the predicate returns `true`.
209
- * The predicate also receives the key.
210
- *
211
- * @example
212
- * ```ts
213
- * pipe(Dict.fromEntries([["a", 1], ["b", 2]]), Dict.filterWithKey((k, v) => k !== "a" && v > 0));
214
- * // ReadonlyMap { "b" => 2 }
215
- * ```
216
- */
217
- const filterWithKey: <K, A>(predicate: (key: K, a: A) => boolean) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>;
218
- /**
219
- * Removes all `None` values from a `ReadonlyMap<K, Option<A>>`, returning a plain
220
- * `ReadonlyMap<K, A>`. Useful when building dictionaries from fallible lookups.
221
- *
222
- * @example
223
- * ```ts
224
- * import { Option } from "@nlozgachev/pipelined/core";
225
- *
226
- * Dict.compact(Dict.fromEntries([
227
- * ["a", Option.some(1)],
228
- * ["b", Option.none()],
229
- * ["c", Option.some(3)],
230
- * ]));
231
- * // ReadonlyMap { "a" => 1, "c" => 3 }
232
- * ```
233
- */
234
- const compact: <K, A>(m: ReadonlyMap<K, Option<A>>) => ReadonlyMap<K, A>;
235
- /**
236
- * Merges two dictionaries. When both contain the same key, the value from `other` takes
237
- * precedence.
238
- *
239
- * @example
240
- * ```ts
241
- * pipe(
242
- * Dict.fromEntries([["a", 1], ["b", 2]]),
243
- * Dict.union(Dict.fromEntries([["b", 3], ["c", 4]])),
244
- * );
245
- * // ReadonlyMap { "a" => 1, "b" => 3, "c" => 4 }
246
- * ```
247
- */
248
- const union: <K, V>(other: ReadonlyMap<K, V>) => (m: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
249
- /**
250
- * Returns a new dictionary containing only the entries whose keys appear in both dictionaries.
251
- * Values are taken from the left (base) dictionary.
252
- *
253
- * @example
254
- * ```ts
255
- * pipe(
256
- * Dict.fromEntries([["a", 1], ["b", 2], ["c", 3]]),
257
- * Dict.intersection(Dict.fromEntries([["b", 99], ["c", 0]])),
258
- * );
259
- * // ReadonlyMap { "b" => 2, "c" => 3 }
260
- * ```
261
- */
262
- const intersection: <K, V>(other: ReadonlyMap<K, unknown>) => (m: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
263
- /**
264
- * Returns a new dictionary containing only the entries whose keys do not appear in `other`.
265
- *
266
- * @example
267
- * ```ts
268
- * pipe(
269
- * Dict.fromEntries([["a", 1], ["b", 2], ["c", 3]]),
270
- * Dict.difference(Dict.fromEntries([["b", 0]])),
271
- * );
272
- * // ReadonlyMap { "a" => 1, "c" => 3 }
273
- * ```
274
- */
275
- const difference: <K, V>(other: ReadonlyMap<K, unknown>) => (m: ReadonlyMap<K, V>) => ReadonlyMap<K, V>;
276
- /**
277
- * Folds the dictionary into a single value by applying `f` to each value in insertion order.
278
- * When you also need the key, use `reduceWithKey`.
279
- *
280
- * @example
281
- * ```ts
282
- * Dict.reduce(0, (acc, value) => acc + value)(
283
- * Dict.fromEntries([["a", 1], ["b", 2], ["c", 3]])
284
- * ); // 6
285
- * ```
286
- */
287
- const reduce: <A, B>(init: B, f: (acc: B, value: A) => B) => <K>(m: ReadonlyMap<K, A>) => B;
288
- /**
289
- * Folds the dictionary into a single value by applying `f` to each key-value pair in insertion
290
- * order.
291
- *
292
- * @example
293
- * ```ts
294
- * Dict.reduceWithKey("", (acc, value, key) => acc + key + ":" + value + " ")(
295
- * Dict.fromEntries([["a", 1], ["b", 2]])
296
- * ); // "a:1 b:2 "
297
- * ```
298
- */
299
- const reduceWithKey: <K, A, B>(init: B, f: (acc: B, value: A, key: K) => B) => (m: ReadonlyMap<K, A>) => B;
300
- /**
301
- * Converts a `ReadonlyMap<string, V>` to a plain object. Only meaningful when keys are strings.
302
- *
303
- * @example
304
- * ```ts
305
- * Dict.toRecord(Dict.fromEntries([["a", 1], ["b", 2]])); // { a: 1, b: 2 }
306
- * ```
307
- */
308
- const toRecord: <V>(m: ReadonlyMap<string, V>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,CAM9G,CAAC;IAMF;;;;;;;OAOG;IACI,MAAM,QAAQ,GAAI,CAAC,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,KAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAA0B,CAAC;CAC7G"}
@@ -1,110 +0,0 @@
1
- import { Option } from "../Core/Option.js";
2
- /**
3
- * Number utilities for common operations. All transformation functions are data-last
4
- * and curried so they compose naturally with `pipe` and `Arr.map`.
5
- *
6
- * @example
7
- * ```ts
8
- * import { Num } from "@nlozgachev/pipelined/utils";
9
- * import { pipe } from "@nlozgachev/pipelined/composition";
10
- *
11
- * pipe(
12
- * Num.range(1, 6),
13
- * Arr.map(Num.multiply(2)),
14
- * Arr.filter(Num.between(4, 8))
15
- * ); // [4, 6, 8]
16
- * ```
17
- */
18
- export declare namespace Num {
19
- /**
20
- * Generates an array of numbers from `from` to `to` (both inclusive),
21
- * stepping by `step` (default `1`). If `step` is negative or zero, or `from > to`,
22
- * returns an empty array. When `step` does not land exactly on `to`, the last value
23
- * is the largest reachable value that does not exceed `to`.
24
- *
25
- * @example
26
- * ```ts
27
- * Num.range(0, 5); // [0, 1, 2, 3, 4, 5]
28
- * Num.range(0, 10, 2); // [0, 2, 4, 6, 8, 10]
29
- * Num.range(0, 9, 2); // [0, 2, 4, 6, 8]
30
- * Num.range(5, 0); // []
31
- * Num.range(3, 3); // [3]
32
- * ```
33
- */
34
- const range: (from: number, to: number, step?: number) => readonly number[];
35
- /**
36
- * Clamps a number between `min` and `max` (both inclusive).
37
- *
38
- * @example
39
- * ```ts
40
- * pipe(150, Num.clamp(0, 100)); // 100
41
- * pipe(-5, Num.clamp(0, 100)); // 0
42
- * pipe(42, Num.clamp(0, 100)); // 42
43
- * ```
44
- */
45
- const clamp: (min: number, max: number) => (n: number) => number;
46
- /**
47
- * Returns `true` when the number is between `min` and `max` (both inclusive).
48
- *
49
- * @example
50
- * ```ts
51
- * pipe(5, Num.between(1, 10)); // true
52
- * pipe(0, Num.between(1, 10)); // false
53
- * pipe(10, Num.between(1, 10)); // true
54
- * ```
55
- */
56
- const between: (min: number, max: number) => (n: number) => boolean;
57
- /**
58
- * Parses a string as a number. Returns `None` when the result is `NaN`.
59
- *
60
- * @example
61
- * ```ts
62
- * Num.parse("42"); // Some(42)
63
- * Num.parse("3.14"); // Some(3.14)
64
- * Num.parse("abc"); // None
65
- * Num.parse(""); // None
66
- * ```
67
- */
68
- const parse: (s: string) => Option<number>;
69
- /**
70
- * Adds `b` to a number. Data-last: use in `pipe` or `Arr.map`.
71
- *
72
- * @example
73
- * ```ts
74
- * pipe(5, Num.add(3)); // 8
75
- * pipe([1, 2, 3], Arr.map(Num.add(10))); // [11, 12, 13]
76
- * ```
77
- */
78
- const add: (b: number) => (a: number) => number;
79
- /**
80
- * Subtracts `b` from a number. Data-last: `subtract(b)(a)` = `a - b`.
81
- *
82
- * @example
83
- * ```ts
84
- * pipe(10, Num.subtract(3)); // 7
85
- * pipe([5, 10, 15], Arr.map(Num.subtract(2))); // [3, 8, 13]
86
- * ```
87
- */
88
- const subtract: (b: number) => (a: number) => number;
89
- /**
90
- * Multiplies a number by `b`. Data-last: use in `pipe` or `Arr.map`.
91
- *
92
- * @example
93
- * ```ts
94
- * pipe(6, Num.multiply(7)); // 42
95
- * pipe([1, 2, 3], Arr.map(Num.multiply(100))); // [100, 200, 300]
96
- * ```
97
- */
98
- const multiply: (b: number) => (a: number) => number;
99
- /**
100
- * Divides a number by `b`. Data-last: `divide(b)(a)` = `a / b`.
101
- *
102
- * @example
103
- * ```ts
104
- * pipe(20, Num.divide(4)); // 5
105
- * pipe([10, 20, 30], Arr.map(Num.divide(10))); // [1, 2, 3]
106
- * ```
107
- */
108
- const divide: (b: number) => (a: number) => number;
109
- }
110
- //# sourceMappingURL=Num.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Num.d.ts","sourceRoot":"","sources":["../../../src/src/Utils/Num.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,yBAAiB,GAAG,CAAC;IACpB;;;;;;;;;;;;;;OAcG;IACI,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,IAAI,MAAM,EAAE,aAAQ,KAAG,SAAS,MAAM,EAQzE,CAAC;IAEF;;;;;;;;;OASG;IACI,MAAM,KAAK,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,MAAM,GAAG,MAAM,KAAG,MAAyC,CAAC;IAE1G;;;;;;;;;OASG;IACI,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,MAAM,GAAG,MAAM,KAAG,OAA+B,CAAC;IAElG;;;;;;;;;;OAUG;IACI,MAAM,KAAK,GAAI,GAAG,MAAM,KAAG,MAAM,CAAC,MAAM,CAI9C,CAAC;IAEF;;;;;;;;OAQG;IACI,MAAM,GAAG,GAAI,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,MAAe,CAAC;IAE/D;;;;;;;;OAQG;IACI,MAAM,QAAQ,GAAI,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,MAAe,CAAC;IAEpE;;;;;;;;OAQG;IACI,MAAM,QAAQ,GAAI,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,MAAe,CAAC;IAEpE;;;;;;;;OAQG;IACI,MAAM,MAAM,GAAI,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,MAAe,CAAC;CAClE"}
@@ -1,159 +0,0 @@
1
- import { Option } from "../Core/Option.js";
2
- /**
3
- * Functional record/object utilities that compose well with pipe.
4
- * All functions are data-last and curried where applicable.
5
- *
6
- * @example
7
- * ```ts
8
- * pipe(
9
- * { a: 1, b: 2, c: 3 },
10
- * Rec.filter(n => n > 1),
11
- * Rec.map(n => n * 10)
12
- * ); // { b: 20, c: 30 }
13
- * ```
14
- */
15
- export declare namespace Rec {
16
- /**
17
- * Transforms each value in a record.
18
- *
19
- * @example
20
- * ```ts
21
- * pipe({ a: 1, b: 2 }, Rec.map(n => n * 2)); // { a: 2, b: 4 }
22
- * ```
23
- */
24
- const map: <A, B>(f: (a: A) => B) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, B>>;
25
- /**
26
- * Transforms each value in a record, also receiving the key.
27
- *
28
- * @example
29
- * ```ts
30
- * pipe({ a: 1, b: 2 }, Rec.mapWithKey((k, v) => `${k}:${v}`));
31
- * // { a: "a:1", b: "b:2" }
32
- * ```
33
- */
34
- const mapWithKey: <A, B>(f: (key: string, a: A) => B) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, B>>;
35
- /**
36
- * Filters values in a record by a predicate.
37
- *
38
- * @example
39
- * ```ts
40
- * pipe({ a: 1, b: 2, c: 3 }, Rec.filter(n => n > 1)); // { b: 2, c: 3 }
41
- * ```
42
- */
43
- const filter: <A>(predicate: (a: A) => boolean) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
44
- /**
45
- * Filters values in a record by a predicate that also receives the key.
46
- *
47
- * @example
48
- * ```ts
49
- * pipe({ a: 1, b: 2 }, Rec.filterWithKey((k, v) => k !== "a" && v > 0));
50
- * // { b: 2 }
51
- * ```
52
- */
53
- const filterWithKey: <A>(predicate: (key: string, a: A) => boolean) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
54
- /**
55
- * Looks up a value by key, returning Option.
56
- *
57
- * @example
58
- * ```ts
59
- * pipe({ a: 1, b: 2 }, Rec.lookup("a")); // Some(1)
60
- * pipe({ a: 1, b: 2 }, Rec.lookup("c")); // None
61
- * ```
62
- */
63
- const lookup: (key: string) => <A>(data: Readonly<Record<string, A>>) => Option<A>;
64
- /**
65
- * Returns all keys of a record.
66
- */
67
- const keys: <A>(data: Readonly<Record<string, A>>) => readonly string[];
68
- /**
69
- * Returns all values of a record.
70
- */
71
- const values: <A>(data: Readonly<Record<string, A>>) => readonly A[];
72
- /**
73
- * Returns all key-value pairs of a record.
74
- */
75
- const entries: <A>(data: Readonly<Record<string, A>>) => readonly (readonly [string, A])[];
76
- /**
77
- * Creates a record from key-value pairs.
78
- *
79
- * @example
80
- * ```ts
81
- * Rec.fromEntries([["a", 1], ["b", 2]]); // { a: 1, b: 2 }
82
- * ```
83
- */
84
- const fromEntries: <A>(data: readonly (readonly [string, A])[]) => Readonly<Record<string, A>>;
85
- /**
86
- * Groups elements of an array into a record keyed by the result of `keyFn`. Each key maps to
87
- * the array of elements that produced it, in insertion order.
88
- *
89
- * Unlike `Dict.groupBy`, keys are always strings. Use `Dict.groupBy` when you need non-string
90
- * keys or want to avoid the plain-object prototype chain.
91
- *
92
- * @example
93
- * ```ts
94
- * pipe(
95
- * ["apple", "avocado", "banana", "blueberry"],
96
- * Rec.groupBy(s => s[0]),
97
- * ); // { a: ["apple", "avocado"], b: ["banana", "blueberry"] }
98
- * ```
99
- */
100
- const groupBy: <A>(keyFn: (a: A) => string) => (items: readonly A[]) => Readonly<Record<string, readonly A[]>>;
101
- /**
102
- * Picks specific keys from a record.
103
- *
104
- * @example
105
- * ```ts
106
- * pipe({ a: 1, b: 2, c: 3 }, Rec.pick("a", "c")); // { a: 1, c: 3 }
107
- * ```
108
- */
109
- const pick: <K extends string>(...pickedKeys: K[]) => <A extends Record<K, unknown>>(data: A) => Pick<A, K>;
110
- /**
111
- * Omits specific keys from a record.
112
- *
113
- * @example
114
- * ```ts
115
- * pipe({ a: 1, b: 2, c: 3 }, Rec.omit("b")); // { a: 1, c: 3 }
116
- * ```
117
- */
118
- const omit: <K extends string>(...omittedKeys: K[]) => <A extends Record<K, unknown>>(data: A) => Omit<A, K>;
119
- /**
120
- * Merges two records. Values from the second record take precedence.
121
- *
122
- * @example
123
- * ```ts
124
- * pipe({ a: 1, b: 2 }, Rec.merge({ b: 3, c: 4 })); // { a: 1, b: 3, c: 4 }
125
- * ```
126
- */
127
- const merge: <A>(other: Readonly<Record<string, A>>) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
128
- /**
129
- * Returns true if the record has no keys.
130
- */
131
- const isEmpty: <A>(data: Readonly<Record<string, A>>) => boolean;
132
- /**
133
- * Returns the number of keys in a record.
134
- */
135
- const size: <A>(data: Readonly<Record<string, A>>) => number;
136
- /**
137
- * Transforms each key while preserving values.
138
- * If two keys map to the same new key, the last one wins.
139
- *
140
- * @example
141
- * ```ts
142
- * pipe({ firstName: "Alice", lastName: "Smith" }, Rec.mapKeys(k => k.toUpperCase()));
143
- * // { FIRSTNAME: "Alice", LASTNAME: "Smith" }
144
- * ```
145
- */
146
- const mapKeys: (f: (key: string) => string) => <A>(data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
147
- /**
148
- * Removes all `None` values from a `Record<string, Option<A>>`, returning a plain `Record<string, A>`.
149
- * Useful when building records from fallible lookups.
150
- *
151
- * @example
152
- * ```ts
153
- * Rec.compact({ a: Option.some(1), b: Option.none(), c: Option.some(3) });
154
- * // { a: 1, c: 3 }
155
- * ```
156
- */
157
- const compact: <A>(data: Readonly<Record<string, Option<A>>>) => Readonly<Record<string, A>>;
158
- }
159
- //# sourceMappingURL=Rec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Rec.d.ts","sourceRoot":"","sources":["../../../src/src/Utils/Rec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,yBAAiB,GAAG,CAAC;IACpB;;;;;;;OAOG;IACI,MAAM,GAAG,GAAI,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAQ3G,CAAC;IAEF;;;;;;;;OAQG;IACI,MAAM,UAAU,GACrB,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,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