@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,158 +0,0 @@
1
- import { Option } from "./Option.js";
2
- import type { Lens } from "./Lens.js";
3
- /** Keys of T for which undefined is assignable (i.e. optional fields). */
4
- type OptionalKeys<T> = {
5
- [K in keyof T]-?: undefined extends T[K] ? K : never;
6
- }[keyof T];
7
- /**
8
- * Optional<S, A> focuses on a value A inside a structure S that may or may
9
- * not be present. Like a Lens, but get returns Option<A>.
10
- *
11
- * Compose with other Optionals via `andThen`, or with a Lens via `andThenLens`.
12
- * Convert a Lens to an Optional with `Lens.toOptional`.
13
- *
14
- * @example
15
- * ```ts
16
- * type Profile = { username: string; bio?: string };
17
- *
18
- * const bioOpt = Optional.prop<Profile>()("bio");
19
- *
20
- * pipe(profile, Optional.get(bioOpt)); // Some("hello") or None
21
- * pipe(profile, Optional.set(bioOpt)("hello")); // new Profile with bio set
22
- * pipe(profile, Optional.modify(bioOpt)(s => s + "!")); // appends if present
23
- * ```
24
- */
25
- export type Optional<S, A> = {
26
- readonly get: (s: S) => Option<A>;
27
- readonly set: (a: A) => (s: S) => S;
28
- };
29
- export declare namespace Optional {
30
- /**
31
- * Constructs an Optional from a getter (returning Option<A>) and a setter.
32
- *
33
- * @example
34
- * ```ts
35
- * const firstChar = Optional.make(
36
- * (s: string) => s.length > 0 ? Option.some(s[0]) : Option.none(),
37
- * (c) => (s) => s.length > 0 ? c + s.slice(1) : s,
38
- * );
39
- * ```
40
- */
41
- const make: <S, A>(get: (s: S) => Option<A>, set: (a: A) => (s: S) => S) => Optional<S, A>;
42
- /**
43
- * Creates an Optional that focuses on an optional property of an object.
44
- * Only keys whose type includes undefined (i.e. `field?: T`) are accepted.
45
- * Call with the structure type first, then the key.
46
- *
47
- * @example
48
- * ```ts
49
- * type Profile = { username: string; bio?: string };
50
- * const bioOpt = Optional.prop<Profile>()("bio");
51
- * ```
52
- */
53
- const prop: <S>() => <K extends OptionalKeys<S>>(key: K) => Optional<S, NonNullable<S[K]>>;
54
- /**
55
- * Creates an Optional that focuses on an element at a given index in an array.
56
- * Returns None when the index is out of bounds; set is a no-op when out of bounds.
57
- *
58
- * @example
59
- * ```ts
60
- * const firstItem = Optional.index<string>(0);
61
- *
62
- * pipe(["a", "b"], Optional.get(firstItem)); // Some("a")
63
- * pipe([], Optional.get(firstItem)); // None
64
- * ```
65
- */
66
- const index: <A>(i: number) => Optional<A[], A>;
67
- /**
68
- * Reads the focused value from a structure, returning Option<A>.
69
- *
70
- * @example
71
- * ```ts
72
- * pipe(profile, Optional.get(bioOpt)); // Some("...") or None
73
- * ```
74
- */
75
- const get: <S, A>(opt: Optional<S, A>) => (s: S) => Option<A>;
76
- /**
77
- * Replaces the focused value within a structure.
78
- * For indexed focuses, this is a no-op when the index is out of bounds.
79
- *
80
- * @example
81
- * ```ts
82
- * pipe(profile, Optional.set(bioOpt)("hello"));
83
- * ```
84
- */
85
- const set: <S, A>(opt: Optional<S, A>) => (a: A) => (s: S) => S;
86
- /**
87
- * Applies a function to the focused value if it is present; returns the
88
- * structure unchanged if the focus is absent.
89
- *
90
- * @example
91
- * ```ts
92
- * pipe(profile, Optional.modify(bioOpt)(s => s.toUpperCase()));
93
- * ```
94
- */
95
- const modify: <S, A>(opt: Optional<S, A>) => (f: (a: A) => A) => (s: S) => S;
96
- /**
97
- * Returns the focused value or a default when the focus is absent.
98
- *
99
- * @example
100
- * ```ts
101
- * pipe(profile, Optional.getOrElse(bioOpt)(() => "no bio"));
102
- * ```
103
- */
104
- const getOrElse: <S, A>(opt: Optional<S, A>) => (defaultValue: () => A) => (s: S) => A;
105
- /**
106
- * Extracts a value from an Optional focus using handlers for the present
107
- * and absent cases.
108
- *
109
- * @example
110
- * ```ts
111
- * pipe(profile, Optional.fold(bioOpt)(() => "no bio", (bio) => bio.toUpperCase()));
112
- * ```
113
- */
114
- const fold: <S, A>(opt: Optional<S, A>) => <B>(onNone: () => B, onSome: (a: A) => B) => (s: S) => B;
115
- /**
116
- * Pattern matches on an Optional focus using a named-case object.
117
- *
118
- * @example
119
- * ```ts
120
- * pipe(
121
- * profile,
122
- * Optional.match(bioOpt)({ none: () => "no bio", some: (bio) => bio }),
123
- * );
124
- * ```
125
- */
126
- const match: <S, A>(opt: Optional<S, A>) => <B>(cases: {
127
- none: () => B;
128
- some: (a: A) => B;
129
- }) => (s: S) => B;
130
- /**
131
- * Composes two Optionals: focuses through the outer, then through the inner.
132
- * Returns None if either focus is absent.
133
- *
134
- * @example
135
- * ```ts
136
- * const deepOpt = pipe(
137
- * Optional.prop<User>()("address"),
138
- * Optional.andThen(Optional.prop<Address>()("landmark")),
139
- * );
140
- * ```
141
- */
142
- const andThen: <A, B>(inner: Optional<A, B>) => <S>(outer: Optional<S, A>) => Optional<S, B>;
143
- /**
144
- * Composes an Optional with a Lens, producing an Optional.
145
- * The Lens focuses within the value found by the Optional.
146
- *
147
- * @example
148
- * ```ts
149
- * const cityOpt = pipe(
150
- * Optional.prop<User>()("address"),
151
- * Optional.andThenLens(Lens.prop<Address>()("city")),
152
- * );
153
- * ```
154
- */
155
- const andThenLens: <A, B>(inner: Lens<A, B>) => <S>(outer: Optional<S, A>) => Optional<S, B>;
156
- }
157
- export {};
158
- //# sourceMappingURL=Optional.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Optional.d.ts","sourceRoot":"","sources":["../../../src/src/Core/Optional.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MA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AE,OAAO,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAU/F,CAAC;IAEH;;;;;;;;;;;OAWG;IACI,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAU/F,CAAC;CACH"}
@@ -1,161 +0,0 @@
1
- import { Refinement } from "./Refinement.js";
2
- /**
3
- * A boolean-valued function over a type `A`.
4
- *
5
- * A `Predicate<A>` is the simpler sibling of `Refinement<A, B>`: it tests whether a
6
- * value satisfies a condition at runtime but carries no compile-time narrowing guarantee.
7
- * Use it when you need to combine, negate, or adapt boolean checks as first-class values
8
- * and do not require the extra type information that a `Refinement` provides.
9
- *
10
- * Every `Refinement<A, B>` is a `Predicate<A>` — convert with `Predicate.fromRefinement`
11
- * when you want to compose a narrowing check alongside plain predicates.
12
- *
13
- * @example
14
- * ```ts
15
- * const isAdult: Predicate<number> = n => n >= 18;
16
- * const isRetired: Predicate<number> = n => n >= 65;
17
- *
18
- * const isWorkingAge: Predicate<number> = pipe(
19
- * isAdult,
20
- * Predicate.and(Predicate.not(isRetired))
21
- * );
22
- *
23
- * isWorkingAge(30); // true
24
- * isWorkingAge(15); // false
25
- * isWorkingAge(70); // false
26
- * ```
27
- */
28
- export type Predicate<A> = (a: A) => boolean;
29
- export declare namespace Predicate {
30
- /**
31
- * Negates a predicate: the result passes exactly when the original fails.
32
- *
33
- * @example
34
- * ```ts
35
- * const isBlank: Predicate<string> = s => s.trim().length === 0;
36
- * const isNotBlank = Predicate.not(isBlank);
37
- *
38
- * isNotBlank("hello"); // true
39
- * isNotBlank(" "); // false
40
- * ```
41
- */
42
- const not: <A>(p: Predicate<A>) => Predicate<A>;
43
- /**
44
- * Combines two predicates with logical AND: passes only when both hold.
45
- *
46
- * Data-last — the first predicate is the data being piped.
47
- *
48
- * @example
49
- * ```ts
50
- * const isPositive: Predicate<number> = n => n > 0;
51
- * const isEven: Predicate<number> = n => n % 2 === 0;
52
- *
53
- * const isPositiveEven: Predicate<number> = pipe(isPositive, Predicate.and(isEven));
54
- *
55
- * isPositiveEven(4); // true
56
- * isPositiveEven(3); // false — positive but odd
57
- * isPositiveEven(-2); // false — even but not positive
58
- * ```
59
- */
60
- const and: <A>(second: Predicate<A>) => (first: Predicate<A>) => Predicate<A>;
61
- /**
62
- * Combines two predicates with logical OR: passes when either holds.
63
- *
64
- * Data-last — the first predicate is the data being piped.
65
- *
66
- * @example
67
- * ```ts
68
- * const isChild: Predicate<number> = n => n < 13;
69
- * const isSenior: Predicate<number> = n => n >= 65;
70
- *
71
- * const getsDiscount: Predicate<number> = pipe(isChild, Predicate.or(isSenior));
72
- *
73
- * getsDiscount(8); // true
74
- * getsDiscount(70); // true
75
- * getsDiscount(30); // false
76
- * ```
77
- */
78
- const or: <A>(second: Predicate<A>) => (first: Predicate<A>) => Predicate<A>;
79
- /**
80
- * Adapts a `Predicate<A>` to work on a different input type `B` by applying `f`
81
- * to extract the relevant `A` from a `B` before running the check.
82
- *
83
- * Data-last — the predicate is the data being piped; `f` is the extractor.
84
- *
85
- * @example
86
- * ```ts
87
- * type User = { name: string; age: number };
88
- *
89
- * const isAdult: Predicate<number> = n => n >= 18;
90
- *
91
- * // Lift isAdult to work on Users by extracting the age field
92
- * const isAdultUser: Predicate<User> = pipe(
93
- * isAdult,
94
- * Predicate.using((u: User) => u.age)
95
- * );
96
- *
97
- * isAdultUser({ name: "Alice", age: 30 }); // true
98
- * isAdultUser({ name: "Bob", age: 15 }); // false
99
- * ```
100
- */
101
- const using: <A, B>(f: (b: B) => A) => (p: Predicate<A>) => Predicate<B>;
102
- /**
103
- * Combines an array of predicates with AND: passes only when every predicate holds.
104
- * Returns `true` for an empty array (vacuous truth).
105
- *
106
- * @example
107
- * ```ts
108
- * const checks: Predicate<string>[] = [
109
- * s => s.length > 0,
110
- * s => s.length <= 100,
111
- * s => !s.includes("<"),
112
- * ];
113
- *
114
- * Predicate.all(checks)("hello"); // true
115
- * Predicate.all(checks)(""); // false — too short
116
- * Predicate.all(checks)("<b>"); // false — contains "<"
117
- * Predicate.all([])("anything"); // true
118
- * ```
119
- */
120
- const all: <A>(predicates: ReadonlyArray<Predicate<A>>) => Predicate<A>;
121
- /**
122
- * Combines an array of predicates with OR: passes when at least one holds.
123
- * Returns `false` for an empty array.
124
- *
125
- * @example
126
- * ```ts
127
- * const acceptedFormats: Predicate<string>[] = [
128
- * s => s.endsWith(".jpg"),
129
- * s => s.endsWith(".png"),
130
- * s => s.endsWith(".webp"),
131
- * ];
132
- *
133
- * Predicate.any(acceptedFormats)("photo.jpg"); // true
134
- * Predicate.any(acceptedFormats)("photo.gif"); // false
135
- * Predicate.any([])("anything"); // false
136
- * ```
137
- */
138
- const any: <A>(predicates: ReadonlyArray<Predicate<A>>) => Predicate<A>;
139
- /**
140
- * Converts a `Refinement<A, B>` into a `Predicate<A>`, discarding the compile-time
141
- * narrowing. Use this when you want to combine a type guard with plain predicates
142
- * using `and`, `or`, or `all`.
143
- *
144
- * @example
145
- * ```ts
146
- * const isString: Refinement<unknown, string> =
147
- * Refinement.make(x => typeof x === "string");
148
- *
149
- * const isShortString: Predicate<unknown> = pipe(
150
- * Predicate.fromRefinement(isString),
151
- * Predicate.and(x => (x as string).length < 10)
152
- * );
153
- *
154
- * isShortString("hi"); // true
155
- * isShortString("a very long string that exceeds ten characters"); // false
156
- * isShortString(42); // false
157
- * ```
158
- */
159
- const fromRefinement: <A, B extends A>(r: Refinement<A, B>) => Predicate<A>;
160
- }
161
- //# sourceMappingURL=Predicate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Predicate.d.ts","sourceRoot":"","sources":["../../../src/src/Core/Predicate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AmBG;IACI,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,SAAS,CAAC,CAAC,CAAM,CAAC;CACvF"}
@@ -1,156 +0,0 @@
1
- /**
2
- * A computation that reads from a shared environment `R` and produces a value `A`.
3
- * Use Reader to thread a dependency (config, logger, DB pool) through a pipeline
4
- * without passing it explicitly to every function.
5
- *
6
- * @example
7
- * ```ts
8
- * type Config = { baseUrl: string; apiKey: string };
9
- *
10
- * const buildUrl = (path: string): Reader<Config, string> =>
11
- * (config) => `${config.baseUrl}${path}`;
12
- *
13
- * const withAuth = (url: string): Reader<Config, string> =>
14
- * (config) => `${url}?key=${config.apiKey}`;
15
- *
16
- * const fetchEndpoint = (path: string): Reader<Config, string> =>
17
- * pipe(
18
- * buildUrl(path),
19
- * Reader.chain(withAuth)
20
- * );
21
- *
22
- * // Inject the config once at the edge
23
- * fetchEndpoint("/users")(appConfig); // "https://api.example.com/users?key=secret"
24
- * ```
25
- */
26
- export type Reader<R, A> = (env: R) => A;
27
- export declare namespace Reader {
28
- /**
29
- * Lifts a pure value into a Reader. The environment is ignored.
30
- *
31
- * @example
32
- * ```ts
33
- * const always42: Reader<Config, number> = Reader.resolve(42);
34
- * always42(anyConfig); // 42
35
- * ```
36
- */
37
- const resolve: <R, A>(value: A) => Reader<R, A>;
38
- /**
39
- * Returns the full environment as the result.
40
- * The fundamental way to access the environment in a pipeline.
41
- *
42
- * @example
43
- * ```ts
44
- * pipe(
45
- * Reader.ask<Config>(),
46
- * Reader.map(config => config.baseUrl)
47
- * )(appConfig); // "https://api.example.com"
48
- * ```
49
- */
50
- const ask: <R>() => Reader<R, R>;
51
- /**
52
- * Projects a value from the environment using a selector function.
53
- * Equivalent to `pipe(Reader.ask(), Reader.map(f))` but more direct.
54
- *
55
- * @example
56
- * ```ts
57
- * const getBaseUrl: Reader<Config, string> = Reader.asks(c => c.baseUrl);
58
- * getBaseUrl(appConfig); // "https://api.example.com"
59
- * ```
60
- */
61
- const asks: <R, A>(f: (env: R) => A) => Reader<R, A>;
62
- /**
63
- * Transforms the value produced by a Reader.
64
- *
65
- * @example
66
- * ```ts
67
- * pipe(
68
- * Reader.asks((c: Config) => c.baseUrl),
69
- * Reader.map(url => url.toUpperCase())
70
- * )(appConfig); // "HTTPS://API.EXAMPLE.COM"
71
- * ```
72
- */
73
- const map: <R, A, B>(f: (a: A) => B) => (data: Reader<R, A>) => Reader<R, B>;
74
- /**
75
- * Sequences two Readers. Both see the same environment.
76
- * The output of the first is passed to `f`, which returns the next Reader.
77
- *
78
- * @example
79
- * ```ts
80
- * const buildUrl = (path: string): Reader<Config, string> =>
81
- * Reader.asks(c => `${c.baseUrl}${path}`);
82
- *
83
- * const addAuth = (url: string): Reader<Config, string> =>
84
- * Reader.asks(c => `${url}?key=${c.apiKey}`);
85
- *
86
- * pipe(
87
- * buildUrl("/items"),
88
- * Reader.chain(addAuth)
89
- * )(appConfig); // "https://api.example.com/items?key=secret"
90
- * ```
91
- */
92
- const chain: <R, A, B>(f: (a: A) => Reader<R, B>) => (data: Reader<R, A>) => Reader<R, B>;
93
- /**
94
- * Applies a function wrapped in a Reader to a value wrapped in a Reader.
95
- * Both Readers see the same environment.
96
- *
97
- * @example
98
- * ```ts
99
- * const add = (a: number) => (b: number) => a + b;
100
- * pipe(
101
- * Reader.resolve<Config, typeof add>(add),
102
- * Reader.ap(Reader.asks(c => c.timeout)),
103
- * Reader.ap(Reader.resolve(5))
104
- * )(appConfig);
105
- * ```
106
- */
107
- const ap: <R, A>(arg: Reader<R, A>) => <B>(data: Reader<R, (a: A) => B>) => Reader<R, B>;
108
- /**
109
- * Executes a side effect on the produced value without changing the Reader.
110
- * Useful for logging or debugging inside a pipeline.
111
- *
112
- * @example
113
- * ```ts
114
- * pipe(
115
- * buildUrl("/users"),
116
- * Reader.tap(url => console.log("Requesting:", url)),
117
- * Reader.chain(addAuth)
118
- * )(appConfig);
119
- * ```
120
- */
121
- const tap: <R, A>(f: (a: A) => void) => (data: Reader<R, A>) => Reader<R, A>;
122
- /**
123
- * Adapts a Reader to work with a different (typically wider) environment
124
- * by transforming the environment before passing it to the Reader.
125
- * This lets you compose Readers that expect different environments.
126
- *
127
- * @example
128
- * ```ts
129
- * type AppEnv = { db: DbPool; config: Config; logger: Logger };
130
- *
131
- * // buildUrl only needs Config
132
- * const buildUrl: Reader<Config, string> = Reader.asks(c => c.baseUrl);
133
- *
134
- * // Zoom in from AppEnv to Config
135
- * const buildUrlFromApp: Reader<AppEnv, string> =
136
- * pipe(buildUrl, Reader.local((env: AppEnv) => env.config));
137
- *
138
- * buildUrlFromApp(appEnv); // works with the full AppEnv
139
- * ```
140
- */
141
- const local: <R2, R>(f: (env: R2) => R) => <A>(data: Reader<R, A>) => Reader<R2, A>;
142
- /**
143
- * Runs a Reader by supplying the environment. Use this at the edge of your
144
- * program where the environment is available.
145
- *
146
- * @example
147
- * ```ts
148
- * pipe(
149
- * buildEndpoint("/users"),
150
- * Reader.run(appConfig)
151
- * ); // "https://api.example.com/users?key=secret"
152
- * ```
153
- */
154
- const run: <R>(env: R) => <A>(data: Reader<R, A>) => A;
155
- }
156
- //# sourceMappingURL=Reader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Reader.d.ts","sourceRoot":"","sources":["../../../src/src/Core/Reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AAEzC,yBAAiB,MAAM,CAAC;IACvB;;;;;;;;OAQG;IACI,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAoB,CAAC;IAEzE;;;;;;;;;;;OAWG;IACI,MAAM,GAAG,GAAI,CAAC,OAAK,MAAM,CAAC,CA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,GAAG,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,EAAE,EAAE,CAAC,CAA0B,CAAC;IAEnH;;;;;;;;;;;OAWG;IACI,MAAM,GAAG,GAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAc,CAAC;CAC1E"}
@@ -1,138 +0,0 @@
1
- import { Option } from "./Option.js";
2
- import { Result } from "./Result.js";
3
- /**
4
- * A function from `A` to `A is B` — a type predicate paired with a runtime check.
5
- *
6
- * A `Refinement<A, B>` proves at compile time that a value of type `A` is actually
7
- * the narrower type `B extends A`, backed by a runtime boolean test. Use it to
8
- * express domain invariants (non-empty strings, positive numbers, valid emails) as
9
- * first-class, composable values rather than one-off type guards scattered across
10
- * the codebase.
11
- *
12
- * @example
13
- * ```ts
14
- * type NonEmptyString = string & { readonly _tag: "NonEmptyString" };
15
- *
16
- * const isNonEmpty: Refinement<string, NonEmptyString> =
17
- * Refinement.make(s => s.length > 0);
18
- *
19
- * pipe(
20
- * "hello",
21
- * Refinement.toFilter(isNonEmpty)
22
- * ); // Some("hello")
23
- * ```
24
- */
25
- export type Refinement<A, B extends A> = (a: A) => a is B;
26
- export declare namespace Refinement {
27
- /**
28
- * Creates a `Refinement<A, B>` from a plain boolean predicate.
29
- *
30
- * This is an unsafe cast — the caller is responsible for ensuring that the
31
- * predicate truly characterises values of type `B`. Use this only when
32
- * bootstrapping a new refinement; prefer `compose`, `and`, or `or` to build
33
- * derived refinements from existing ones.
34
- *
35
- * @example
36
- * ```ts
37
- * type PositiveNumber = number & { readonly _tag: "PositiveNumber" };
38
- *
39
- * const isPositive: Refinement<number, PositiveNumber> =
40
- * Refinement.make(n => n > 0);
41
- * ```
42
- */
43
- const make: <A, B extends A>(f: (a: A) => boolean) => Refinement<A, B>;
44
- /**
45
- * Chains two refinements: if `ab` narrows `A` to `B` and `bc` narrows `B` to `C`,
46
- * the result narrows `A` directly to `C`.
47
- *
48
- * Data-last — the first refinement `ab` is the data being piped.
49
- *
50
- * @example
51
- * ```ts
52
- * type NonEmptyString = string & { readonly _tag: "NonEmpty" };
53
- * type TrimmedString = NonEmptyString & { readonly _tag: "Trimmed" };
54
- *
55
- * const isNonEmpty: Refinement<string, NonEmptyString> =
56
- * Refinement.make(s => s.length > 0);
57
- * const isTrimmed: Refinement<NonEmptyString, TrimmedString> =
58
- * Refinement.make(s => s === s.trim());
59
- *
60
- * const isNonEmptyTrimmed: Refinement<string, TrimmedString> = pipe(
61
- * isNonEmpty,
62
- * Refinement.compose(isTrimmed)
63
- * );
64
- * ```
65
- */
66
- const compose: <A, B extends A, C extends B>(bc: Refinement<B, C>) => (ab: Refinement<A, B>) => Refinement<A, C>;
67
- /**
68
- * Intersects two refinements: the result narrows `A` to `B & C`, passing only
69
- * when both refinements hold simultaneously.
70
- *
71
- * Data-last — the first refinement is the data being piped.
72
- *
73
- * @example
74
- * ```ts
75
- * const isString: Refinement<unknown, string> = Refinement.make(x => typeof x === "string");
76
- * const isNonEmpty: Refinement<unknown, { length: number }> =
77
- * Refinement.make(x => (x as any).length > 0);
78
- *
79
- * const isNonEmptyString = pipe(isString, Refinement.and(isNonEmpty));
80
- * isNonEmptyString("hi"); // true
81
- * isNonEmptyString(""); // false
82
- * ```
83
- */
84
- const and: <A, C extends A>(second: Refinement<A, C>) => <B extends A>(first: Refinement<A, B>) => Refinement<A, B & C>;
85
- /**
86
- * Unions two refinements: the result narrows `A` to `B | C`, passing when either
87
- * refinement holds.
88
- *
89
- * Data-last — the first refinement is the data being piped.
90
- *
91
- * @example
92
- * ```ts
93
- * const isString: Refinement<unknown, string> = Refinement.make(x => typeof x === "string");
94
- * const isNumber: Refinement<unknown, number> = Refinement.make(x => typeof x === "number");
95
- *
96
- * const isStringOrNumber = pipe(isString, Refinement.or(isNumber));
97
- * isStringOrNumber("hi"); // true
98
- * isStringOrNumber(42); // true
99
- * isStringOrNumber(true); // false
100
- * ```
101
- */
102
- const or: <A, C extends A>(second: Refinement<A, C>) => <B extends A>(first: Refinement<A, B>) => Refinement<A, B | C>;
103
- /**
104
- * Converts a `Refinement<A, B>` into a function `(a: A) => Option<B>`.
105
- *
106
- * Returns `Some(a)` when the refinement holds, `None` otherwise. Useful for
107
- * integrating runtime validation into an `Option`-based pipeline.
108
- *
109
- * @example
110
- * ```ts
111
- * type PositiveNumber = number & { readonly _tag: "Positive" };
112
- * const isPositive: Refinement<number, PositiveNumber> =
113
- * Refinement.make(n => n > 0);
114
- *
115
- * pipe(-1, Refinement.toFilter(isPositive)); // None
116
- * pipe(42, Refinement.toFilter(isPositive)); // Some(42)
117
- * ```
118
- */
119
- const toFilter: <A, B extends A>(r: Refinement<A, B>) => (a: A) => Option<B>;
120
- /**
121
- * Converts a `Refinement<A, B>` into a function `(a: A) => Result<E, B>`.
122
- *
123
- * Returns `Ok(a)` when the refinement holds, `Err(onFail(a))` otherwise. Use
124
- * this to surface validation failures as typed errors inside a `Result` pipeline.
125
- *
126
- * @example
127
- * ```ts
128
- * type NonEmptyString = string & { readonly _tag: "NonEmpty" };
129
- * const isNonEmpty: Refinement<string, NonEmptyString> =
130
- * Refinement.make(s => s.length > 0);
131
- *
132
- * pipe("", Refinement.toResult(isNonEmpty, () => "must not be empty")); // Err(...)
133
- * pipe("hi", Refinement.toResult(isNonEmpty, () => "must not be empty")); // Ok("hi")
134
- * ```
135
- */
136
- const toResult: <A, B extends A, E>(r: Refinement<A, B>, onFail: (a: A) => E) => (a: A) => Result<E, B>;
137
- }
138
- //# sourceMappingURL=Refinement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Refinement.d.ts","sourceRoot":"","sources":["../../../src/src/Core/Refinement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;A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