@nlozgachev/pipekit 0.1.6 → 0.1.8

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.
@@ -0,0 +1,115 @@
1
+ import { NonEmptyList } from "../Types/NonEmptyList.js";
2
+ import { Task } from "./Task.js";
3
+ import { Validation } from "./Validation.js";
4
+ /**
5
+ * A Task that resolves to a Validation — combining async operations with
6
+ * error accumulation. Unlike TaskResult, multiple failures are collected
7
+ * rather than short-circuiting on the first error.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const validateName = (name: string): TaskValidation<string, string> =>
12
+ * name.length > 0
13
+ * ? TaskValidation.of(name)
14
+ * : TaskValidation.fail("Name is required");
15
+ *
16
+ * // Accumulate errors from multiple async validations using ap
17
+ * pipe(
18
+ * TaskValidation.of((name: string) => (age: number) => ({ name, age })),
19
+ * TaskValidation.ap(validateName("")),
20
+ * TaskValidation.ap(validateAge(-1))
21
+ * )();
22
+ * // Invalid(["Name is required", "Age must be positive"])
23
+ * ```
24
+ */
25
+ export type TaskValidation<E, A> = Task<Validation<E, A>>;
26
+ export declare namespace TaskValidation {
27
+ /**
28
+ * Wraps a value in a valid TaskValidation.
29
+ */
30
+ const of: <E, A>(value: A) => TaskValidation<E, A>;
31
+ /**
32
+ * Creates a failed TaskValidation with a single error.
33
+ */
34
+ const fail: <E, A>(error: E) => TaskValidation<E, A>;
35
+ /**
36
+ * Lifts a Validation into a TaskValidation.
37
+ */
38
+ const fromValidation: <E, A>(validation: Validation<E, A>) => TaskValidation<E, A>;
39
+ /**
40
+ * Creates a TaskValidation from a Promise-returning function.
41
+ * Catches any errors and transforms them using the onError function.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const fetchUser = (id: string): TaskValidation<string, User> =>
46
+ * TaskValidation.tryCatch(
47
+ * () => fetch(`/users/${id}`).then(r => r.json()),
48
+ * e => `Failed to fetch user: ${e}`
49
+ * );
50
+ * ```
51
+ */
52
+ const tryCatch: <E, A>(f: () => Promise<A>, onError: (e: unknown) => E) => TaskValidation<E, A>;
53
+ /**
54
+ * Transforms the success value inside a TaskValidation.
55
+ */
56
+ const map: <E, A, B>(f: (a: A) => B) => (data: TaskValidation<E, A>) => TaskValidation<E, B>;
57
+ /**
58
+ * Chains TaskValidation computations. If the first is Valid, passes the value
59
+ * to f. If the first is Invalid, propagates the errors.
60
+ *
61
+ * Note: chain short-circuits on first error. Use ap to accumulate errors.
62
+ */
63
+ const chain: <E, A, B>(f: (a: A) => TaskValidation<E, B>) => (data: TaskValidation<E, A>) => TaskValidation<E, B>;
64
+ /**
65
+ * Applies a function wrapped in a TaskValidation to a value wrapped in a
66
+ * TaskValidation. Both Tasks run in parallel and errors from both sides
67
+ * are accumulated.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * pipe(
72
+ * TaskValidation.of((name: string) => (age: number) => ({ name, age })),
73
+ * TaskValidation.ap(validateName(name)),
74
+ * TaskValidation.ap(validateAge(age))
75
+ * )();
76
+ * ```
77
+ */
78
+ const ap: <E, A>(arg: TaskValidation<E, A>) => <B>(data: TaskValidation<E, (a: A) => B>) => TaskValidation<E, B>;
79
+ /**
80
+ * Extracts a value from a TaskValidation by providing handlers for both cases.
81
+ */
82
+ const fold: <E, A, B>(onInvalid: (errors: NonEmptyList<E>) => B, onValid: (a: A) => B) => (data: TaskValidation<E, A>) => Task<B>;
83
+ /**
84
+ * Pattern matches on a TaskValidation, returning a Task of the result.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * pipe(
89
+ * validateForm(input),
90
+ * TaskValidation.match({
91
+ * valid: data => save(data),
92
+ * invalid: errors => showErrors(errors)
93
+ * })
94
+ * )();
95
+ * ```
96
+ */
97
+ const match: <E, A, B>(cases: {
98
+ valid: (a: A) => B;
99
+ invalid: (errors: NonEmptyList<E>) => B;
100
+ }) => (data: TaskValidation<E, A>) => Task<B>;
101
+ /**
102
+ * Returns the success value or a default value if the TaskValidation is invalid.
103
+ */
104
+ const getOrElse: <E, A>(defaultValue: A) => (data: TaskValidation<E, A>) => Task<A>;
105
+ /**
106
+ * Executes a side effect on the success value without changing the TaskValidation.
107
+ * Useful for logging or debugging.
108
+ */
109
+ const tap: <E, A>(f: (a: A) => void) => (data: TaskValidation<E, A>) => TaskValidation<E, A>;
110
+ /**
111
+ * Recovers from an Invalid state by providing a fallback TaskValidation.
112
+ */
113
+ const recover: <E, A>(fallback: () => TaskValidation<E, A>) => (data: TaskValidation<E, A>) => TaskValidation<E, A>;
114
+ }
115
+ //# sourceMappingURL=TaskValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskValidation.d.ts","sourceRoot":"","sources":["../../../src/src/Core/TaskValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE1D,yBAAiB,cAAc,CAAC;IAC9B;;OAEG;IACI,MAAM,EAAE,GAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAkC,CAAC;IAE1F;;OAEG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAoC,CAAC;IAE9F;;OAEG;IACI,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,EAAE,YAAY,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAClE,CAAC;IAEtB;;;;;;;;;;;;OAYG;IACI,MAAM,QAAQ,GAAI,CAAC,EAAE,CA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CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAAC,OAAO,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;KAAE,MAC/E,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,IAAI,CAAC,CAAC,CAAqD,CAAC;IAE5F;;OAEG;IACI,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,IAAI,CAAC,CAAC,CAC9B,CAAC;IAE3D;;;OAGG;IACI,MAAM,GAAG,GACb,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CACrC,CAAC;IAE5C;;OAEG;IACI,MAAM,OAAO,GACjB,CAAC,EAAE,CAAC,EAAE,UAAU,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAC1C,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAGxC,CAAC;CACb"}
@@ -0,0 +1,213 @@
1
+ import { Err, Ok, Result } from "./Result.js";
2
+ import { WithError, WithKind, WithValue } from "./InternalTypes.js";
3
+ /**
4
+ * These<E, A> is an inclusive-OR type: it holds an error value (E), a success
5
+ * value (A), or both simultaneously. It reuses Ok<A> and Err<E> from Result,
6
+ * adding a third Both<E, A> variant for partial success with a warning/error.
7
+ *
8
+ * - Err(e) — only an error/warning (no success value)
9
+ * - Ok(a) — only a success value (no error)
10
+ * - Both(e, a) — a warning together with a success value
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const parse = (s: string): These<string, number> => {
15
+ * const n = parseFloat(s.trim());
16
+ * if (isNaN(n)) return These.toErr("Not a number");
17
+ * if (s !== s.trim()) return These.toBoth("Leading/trailing whitespace trimmed", n);
18
+ * return These.toOk(n);
19
+ * };
20
+ * ```
21
+ */
22
+ export type These<E, A> = Err<E> | Ok<A> | Both<E, A>;
23
+ export type Both<E, A> = WithKind<"Both"> & WithError<E> & WithValue<A>;
24
+ export declare namespace These {
25
+ /**
26
+ * Creates a These holding only an error/warning (no success value).
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * These.toErr("Something went wrong");
31
+ * ```
32
+ */
33
+ const toErr: <E>(error: E) => Err<E>;
34
+ /**
35
+ * Creates a These holding only a success value (no error).
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * These.toOk(42);
40
+ * ```
41
+ */
42
+ const toOk: <A>(value: A) => Ok<A>;
43
+ /**
44
+ * Creates a These holding both an error/warning and a success value.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * These.toBoth("Deprecated API used", result);
49
+ * ```
50
+ */
51
+ const toBoth: <E, A>(error: E, value: A) => Both<E, A>;
52
+ /**
53
+ * Type guard — checks if a These holds only an error/warning.
54
+ */
55
+ const isErr: <E, A>(data: These<E, A>) => data is Err<E>;
56
+ /**
57
+ * Type guard — checks if a These holds only a success value.
58
+ */
59
+ const isOk: <E, A>(data: These<E, A>) => data is Ok<A>;
60
+ /**
61
+ * Type guard — checks if a These holds both an error/warning and a success value.
62
+ */
63
+ const isBoth: <E, A>(data: These<E, A>) => data is Both<E, A>;
64
+ /**
65
+ * Returns true if the These contains a success value (Ok or Both).
66
+ */
67
+ const hasValue: <E, A>(data: These<E, A>) => data is Ok<A> | Both<E, A>;
68
+ /**
69
+ * Returns true if the These contains an error/warning (Err or Both).
70
+ */
71
+ const hasError: <E, A>(data: These<E, A>) => data is Err<E> | Both<E, A>;
72
+ /**
73
+ * Transforms the success value, leaving the error unchanged.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * pipe(These.toOk(5), These.map(n => n * 2)); // Ok(10)
78
+ * pipe(These.toBoth("warn", 5), These.map(n => n * 2)); // Both("warn", 10)
79
+ * pipe(These.toErr("err"), These.map(n => n * 2)); // Err("err")
80
+ * ```
81
+ */
82
+ const map: <A, B>(f: (a: A) => B) => <E>(data: These<E, A>) => These<E, B>;
83
+ /**
84
+ * Transforms the error/warning value, leaving the success value unchanged.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * pipe(These.toErr("err"), These.mapErr(e => e.toUpperCase())); // Err("ERR")
89
+ * pipe(These.toBoth("warn", 5), These.mapErr(e => e.toUpperCase())); // Both("WARN", 5)
90
+ * ```
91
+ */
92
+ const mapErr: <E, F>(f: (e: E) => F) => <A>(data: These<E, A>) => These<F, A>;
93
+ /**
94
+ * Transforms both the error and success values independently.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * pipe(
99
+ * These.toBoth("warn", 5),
100
+ * These.bimap(e => e.toUpperCase(), n => n * 2)
101
+ * ); // Both("WARN", 10)
102
+ * ```
103
+ */
104
+ const bimap: <E, F, A, B>(onErr: (e: E) => F, onOk: (a: A) => B) => (data: These<E, A>) => These<F, B>;
105
+ /**
106
+ * Chains These computations by passing the success value to f.
107
+ * - Err propagates unchanged.
108
+ * - Ok(a) applies f(a) directly.
109
+ * - Both(e, a): applies f(a); if the result is Ok(b), returns Both(e, b)
110
+ * to preserve the warning. Otherwise returns f(a) as-is.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * const double = (n: number): These<string, number> => These.toOk(n * 2);
115
+ *
116
+ * pipe(These.toOk(5), These.chain(double)); // Ok(10)
117
+ * pipe(These.toBoth("warn", 5), These.chain(double)); // Both("warn", 10)
118
+ * pipe(These.toErr("err"), These.chain(double)); // Err("err")
119
+ * ```
120
+ */
121
+ const chain: <E, A, B>(f: (a: A) => These<E, B>) => (data: These<E, A>) => These<E, B>;
122
+ /**
123
+ * Extracts a value from a These by providing handlers for all three cases.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * pipe(
128
+ * these,
129
+ * These.fold(
130
+ * e => `Error: ${e}`,
131
+ * a => `Value: ${a}`,
132
+ * (e, a) => `Both: ${e} / ${a}`
133
+ * )
134
+ * );
135
+ * ```
136
+ */
137
+ const fold: <E, A, B>(onErr: (e: E) => B, onOk: (a: A) => B, onBoth: (e: E, a: A) => B) => (data: These<E, A>) => B;
138
+ /**
139
+ * Pattern matches on a These, returning the result of the matching case.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * pipe(
144
+ * these,
145
+ * These.match({
146
+ * err: e => `Error: ${e}`,
147
+ * ok: a => `Value: ${a}`,
148
+ * both: (e, a) => `Both: ${e} / ${a}`
149
+ * })
150
+ * );
151
+ * ```
152
+ */
153
+ const match: <E, A, B>(cases: {
154
+ err: (e: E) => B;
155
+ ok: (a: A) => B;
156
+ both: (e: E, a: A) => B;
157
+ }) => (data: These<E, A>) => B;
158
+ /**
159
+ * Returns the success value, or a default if the These has no success value.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * pipe(These.toOk(5), These.getOrElse(0)); // 5
164
+ * pipe(These.toBoth("warn", 5), These.getOrElse(0)); // 5
165
+ * pipe(These.toErr("err"), These.getOrElse(0)); // 0
166
+ * ```
167
+ */
168
+ const getOrElse: <A>(defaultValue: A) => <E>(data: These<E, A>) => A;
169
+ /**
170
+ * Executes a side effect on the success value without changing the These.
171
+ * Useful for logging or debugging.
172
+ */
173
+ const tap: <A>(f: (a: A) => void) => <E>(data: These<E, A>) => These<E, A>;
174
+ /**
175
+ * Swaps the roles of error and success values.
176
+ * - Err(e) → Ok(e)
177
+ * - Ok(a) → Err(a)
178
+ * - Both(e, a) → Both(a, e)
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * These.swap(These.toErr("err")); // Ok("err")
183
+ * These.swap(These.toOk(5)); // Err(5)
184
+ * These.swap(These.toBoth("warn", 5)); // Both(5, "warn")
185
+ * ```
186
+ */
187
+ const swap: <E, A>(data: These<E, A>) => These<A, E>;
188
+ /**
189
+ * Converts a These to an Option.
190
+ * Ok and Both produce Some; Err produces None.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * These.toOption(These.toOk(42)); // Some(42)
195
+ * These.toOption(These.toBoth("warn", 42)); // Some(42)
196
+ * These.toOption(These.toErr("err")); // None
197
+ * ```
198
+ */
199
+ const toOption: <E, A>(data: These<E, A>) => import("./Option.ts").Option<A>;
200
+ /**
201
+ * Converts a These to a Result, discarding any warning from Both.
202
+ * Ok and Both produce Ok; Err produces Err.
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * These.toResult(These.toOk(42)); // Ok(42)
207
+ * These.toResult(These.toBoth("warn", 42)); // Ok(42)
208
+ * These.toResult(These.toErr("err")); // Err("err")
209
+ * ```
210
+ */
211
+ const toResult: <E, A>(data: These<E, A>) => Result<E, A>;
212
+ }
213
+ //# sourceMappingURL=These.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"These.d.ts","sourceRoot":"","sources":["../../../src/src/Core/These.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEtD,MAAM,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAExE,yBAAiB,KAAK,CAAC;IACrB;;;;;;;OAOG;IACI,MAAM,KAAK,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,GAAG,CAAC,CAAC,CAAwB,CAAC;IAElE;;;;;;;OAOG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,EAAE,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KAAK,CAAC,CAAC;QACjB,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAChB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;KACzB,MACA,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAIpB,CAAC;IAEF;;;;;;;;;OASG;IACI,MAAM,SAAS,GAAI,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAC7B,CAAC;IAE7C;;;OAGG;IACI,MAAM,GAAG,GAAI,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAG9E,CAAC;IAEF;;;;;;;;;;;;OAYG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAIxD,CAAC;IAEF;;;;;;;;;;OAUG;IACI,MAAM,QAAQ,GAAI,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,OAAO,aAAa,EAAE,MAAM,CAAC,CAAC,CACR,CAAC;IAE1E;;;;;;;;;;OAUG;IACI,MAAM,QAAQ,GAAI,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAG7D,CAAC;CACH"}
@@ -4,6 +4,9 @@ export * from "./Rec.js";
4
4
  export * from "./RemoteData.js";
5
5
  export * from "./Result.js";
6
6
  export * from "./Task.js";
7
+ export * from "./TaskOption.js";
7
8
  export * from "./TaskResult.js";
9
+ export * from "./TaskValidation.js";
10
+ export * from "./These.js";
8
11
  export * from "./Validation.js";
9
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,52 @@
1
+ declare const _brand: unique symbol;
2
+ /**
3
+ * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
4
+ * Prevents accidentally mixing up values that share the same underlying type.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * type UserId = Brand<"UserId", string>;
9
+ * type ProductId = Brand<"ProductId", string>;
10
+ *
11
+ * const toUserId = Brand.make<"UserId", string>();
12
+ * const toProductId = Brand.make<"ProductId", string>();
13
+ *
14
+ * const userId: UserId = toUserId("user-123");
15
+ * const productId: ProductId = toProductId("prod-456");
16
+ *
17
+ * // Type error: ProductId is not assignable to UserId
18
+ * // const wrong: UserId = productId;
19
+ * ```
20
+ */
21
+ export type Brand<K extends string, T> = T & {
22
+ readonly [_brand]: K;
23
+ };
24
+ export declare namespace Brand {
25
+ /**
26
+ * Creates a branding constructor for brand K over type T.
27
+ * The resulting function performs an unchecked cast — only use when the raw
28
+ * value is known to satisfy the brand's invariants.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * type PositiveNumber = Brand<"PositiveNumber", number>;
33
+ * const toPositiveNumber = Brand.make<"PositiveNumber", number>();
34
+ *
35
+ * const n: PositiveNumber = toPositiveNumber(42);
36
+ * ```
37
+ */
38
+ const make: <K extends string, T>() => (value: T) => Brand<K, T>;
39
+ /**
40
+ * Strips the brand and returns the underlying value.
41
+ * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const userId: UserId = toUserId("user-123");
46
+ * const raw: string = Brand.unwrap(userId); // "user-123"
47
+ * ```
48
+ */
49
+ const unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
50
+ }
51
+ export {};
52
+ //# sourceMappingURL=Brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../../src/src/Types/Brand.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAEtE,yBAAiB,KAAK,CAAC;IACrB;;;;;;;;;;;;OAYG;IACI,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,QAAQ,OAAO,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAyB,CAAC;IAE/F;;;;;;;;;OASG;IACI,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAiB,CAAC;CACtF"}
@@ -1,2 +1,3 @@
1
+ export * from "./Brand.js";
1
2
  export * from "./NonEmptyList.js";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}