wellcrafted 0.21.4 → 0.22.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.
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.js +1 -1
- package/dist/{index-CS5xkzx0.d.ts → index-PgMy4LEz.d.ts} +2 -2
- package/dist/{index-CS5xkzx0.d.ts.map → index-PgMy4LEz.d.ts.map} +1 -1
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +2 -2
- package/dist/result/index.d.ts +2 -2
- package/dist/result/index.js +2 -2
- package/dist/{result-BPrctj1f.js → result-B1iWFqM9.js} +5 -85
- package/dist/{result-BPrctj1f.js.map → result-B1iWFqM9.js.map} +1 -1
- package/dist/{result-DucAuR8u.d.ts → result-DRq8PMRe.d.ts} +71 -81
- package/dist/result-DRq8PMRe.d.ts.map +1 -0
- package/dist/{result-DOgvmaNP.js → result-DfuKgZo9.js} +2 -2
- package/dist/{result-DOgvmaNP.js.map → result-DfuKgZo9.js.map} +1 -1
- package/package.json +1 -1
- package/dist/result-DucAuR8u.d.ts.map +0 -1
package/dist/error/index.d.ts
CHANGED
package/dist/error/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Err, Ok, Result } from "./result-
|
|
1
|
+
import { Err, Ok, Result } from "./result-DRq8PMRe.js";
|
|
2
2
|
|
|
3
3
|
//#region src/result/utils.d.ts
|
|
4
4
|
|
|
@@ -25,4 +25,4 @@ declare function partitionResults<T, E>(results: Result<T, E>[]): {
|
|
|
25
25
|
//# sourceMappingURL=utils.d.ts.map
|
|
26
26
|
//#endregion
|
|
27
27
|
export { partitionResults };
|
|
28
|
-
//# sourceMappingURL=index-
|
|
28
|
+
//# sourceMappingURL=index-PgMy4LEz.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-PgMy4LEz.d.ts","names":[],"sources":["../src/result/utils.ts"],"sourcesContent":[],"mappings":";;;;;;AAmBA;;;;;;;;;AAK+B;;;;;iBALf,gCAAgC,OAAO,GAAG;OAK7C,GAAG;QAAY,IAAI"}
|
package/dist/query/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Result } from "../result-
|
|
2
|
-
import "../index-
|
|
1
|
+
import { Result } from "../result-DRq8PMRe.js";
|
|
2
|
+
import "../index-PgMy4LEz.js";
|
|
3
3
|
import { DefaultError, MutationFunction, MutationKey, MutationOptions, QueryClient, QueryFunction, QueryKey, QueryObserverOptions } from "@tanstack/query-core";
|
|
4
4
|
|
|
5
5
|
//#region src/query/utils.d.ts
|
package/dist/query/index.js
CHANGED
package/dist/result/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Err, ExtractErrFromResult, ExtractOkFromResult, Ok, Result, UnwrapErr, UnwrapOk, isErr, isOk, isResult, resolve, tryAsync, trySync, unwrap } from "../result-
|
|
2
|
-
import { partitionResults } from "../index-
|
|
1
|
+
import { Err, ExtractErrFromResult, ExtractOkFromResult, Ok, Result, UnwrapErr, UnwrapOk, isErr, isOk, isResult, resolve, tryAsync, trySync, unwrap } from "../result-DRq8PMRe.js";
|
|
2
|
+
import { partitionResults } from "../index-PgMy4LEz.js";
|
|
3
3
|
export { Err, ExtractErrFromResult, ExtractOkFromResult, Ok, Result, UnwrapErr, UnwrapOk, isErr, isOk, isResult, partitionResults, resolve, tryAsync, trySync, unwrap };
|
package/dist/result/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Err, Ok, isErr, isOk, isResult, resolve, tryAsync, trySync, unwrap } from "../result-
|
|
2
|
-
import { partitionResults } from "../result-
|
|
1
|
+
import { Err, Ok, isErr, isOk, isResult, resolve, tryAsync, trySync, unwrap } from "../result-B1iWFqM9.js";
|
|
2
|
+
import { partitionResults } from "../result-DfuKgZo9.js";
|
|
3
3
|
|
|
4
4
|
export { Err, Ok, isErr, isOk, isResult, partitionResults, resolve, tryAsync, trySync, unwrap };
|
|
@@ -124,100 +124,20 @@ function isOk(result) {
|
|
|
124
124
|
function isErr(result) {
|
|
125
125
|
return result.error !== null;
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
* Executes a synchronous operation and wraps its outcome (success or failure) in a `Result<T, E>`.
|
|
129
|
-
*
|
|
130
|
-
* This function attempts to execute the `operation`.
|
|
131
|
-
* - If `operation` completes successfully, its return value is wrapped in an `Ok<T>` variant.
|
|
132
|
-
* - If `operation` throws an exception, the caught exception (of type `unknown`) is passed to
|
|
133
|
-
* the `mapErr` function. `mapErr` is responsible for transforming this `unknown`
|
|
134
|
-
* exception into an `Err<E>` variant containing a well-typed error value of type `E`.
|
|
135
|
-
*
|
|
136
|
-
* @template T - The type of the success value returned by the `operation` if it succeeds.
|
|
137
|
-
* @template E - The type of the error value produced by `mapErr` if the `operation` fails.
|
|
138
|
-
* @param options - An object containing the operation and error mapping function.
|
|
139
|
-
* @param options.try - The synchronous operation to execute. This function is expected to return a value of type `T`.
|
|
140
|
-
* @param options.mapErr - A function that takes the `unknown` exception caught from `options.try`
|
|
141
|
-
* and transforms it into an `Err<E>` variant containing a specific error value of type `E`.
|
|
142
|
-
* @returns A `Result<T, E>`: `Ok<T>` if `options.try` succeeds, or `Err<E>` if it throws and `options.mapErr` provides an error variant.
|
|
143
|
-
* @example
|
|
144
|
-
* ```ts
|
|
145
|
-
* function parseJson(jsonString: string): Result<object, SyntaxError> {
|
|
146
|
-
* return trySync({
|
|
147
|
-
* try: () => JSON.parse(jsonString),
|
|
148
|
-
* mapErr: (err: unknown) => {
|
|
149
|
-
* if (err instanceof SyntaxError) return Err(err);
|
|
150
|
-
* return Err(new SyntaxError("Unknown parsing error"));
|
|
151
|
-
* }
|
|
152
|
-
* });
|
|
153
|
-
* }
|
|
154
|
-
*
|
|
155
|
-
* const validResult = parseJson('{"name":"Result"}'); // Ok<{name: string}>
|
|
156
|
-
* const invalidResult = parseJson('invalid json'); // Err<SyntaxError>
|
|
157
|
-
*
|
|
158
|
-
* if (isOk(validResult)) console.log(validResult.data);
|
|
159
|
-
* if (isErr(invalidResult)) console.error(invalidResult.error.message);
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
function trySync({ try: operation, mapErr }) {
|
|
127
|
+
function trySync({ try: operation, catch: catchFn }) {
|
|
163
128
|
try {
|
|
164
129
|
const data = operation();
|
|
165
130
|
return Ok(data);
|
|
166
131
|
} catch (error) {
|
|
167
|
-
return
|
|
132
|
+
return catchFn(error);
|
|
168
133
|
}
|
|
169
134
|
}
|
|
170
|
-
|
|
171
|
-
* Executes an asynchronous operation (returning a `Promise`) and wraps its outcome in a `Promise<Result<T, E>>`.
|
|
172
|
-
*
|
|
173
|
-
* This function attempts to execute the asynchronous `operation`.
|
|
174
|
-
* - If the `Promise` returned by `operation` resolves successfully, its resolved value is wrapped in an `Ok<T>` variant.
|
|
175
|
-
* - If the `Promise` returned by `operation` rejects, or if `operation` itself throws an exception synchronously,
|
|
176
|
-
* the caught exception/rejection reason (of type `unknown`) is passed to the `mapErr` function.
|
|
177
|
-
* `mapErr` is responsible for transforming this `unknown` error into an `Err<E>` variant containing
|
|
178
|
-
* a well-typed error value of type `E`.
|
|
179
|
-
*
|
|
180
|
-
* The entire outcome (`Ok<T>` or `Err<E>`) is wrapped in a `Promise`.
|
|
181
|
-
*
|
|
182
|
-
* @template T - The type of the success value the `Promise` from `operation` resolves to.
|
|
183
|
-
* @template E - The type of the error value produced by `mapErr` if the `operation` fails or rejects.
|
|
184
|
-
* @param options - An object containing the asynchronous operation and error mapping function.
|
|
185
|
-
* @param options.try - The asynchronous operation to execute. This function must return a `Promise<T>`.
|
|
186
|
-
* @param options.mapErr - A function that takes the `unknown` exception/rejection reason caught from `options.try`
|
|
187
|
-
* and transforms it into an `Err<E>` variant containing a specific error value of type `E`.
|
|
188
|
-
* This function must return `Err<E>` directly.
|
|
189
|
-
* @returns A `Promise` that resolves to a `Result<T, E>`: `Ok<T>` if `options.try`'s `Promise` resolves,
|
|
190
|
-
* or `Err<E>` if it rejects/throws and `options.mapErr` provides an error variant.
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* async function fetchData(url: string): Promise<Result<Response, Error>> {
|
|
194
|
-
* return tryAsync({
|
|
195
|
-
* try: async () => fetch(url),
|
|
196
|
-
* mapErr: (err: unknown) => {
|
|
197
|
-
* if (err instanceof Error) return Err(err);
|
|
198
|
-
* return Err(new Error("Network request failed"));
|
|
199
|
-
* }
|
|
200
|
-
* });
|
|
201
|
-
* }
|
|
202
|
-
*
|
|
203
|
-
* async function processData() {
|
|
204
|
-
* const result = await fetchData("/api/data");
|
|
205
|
-
* if (isOk(result)) {
|
|
206
|
-
* const response = result.data;
|
|
207
|
-
* console.log("Data fetched:", await response.json());
|
|
208
|
-
* } else {
|
|
209
|
-
* console.error("Fetch error:", result.error.message);
|
|
210
|
-
* }
|
|
211
|
-
* }
|
|
212
|
-
* processData();
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
async function tryAsync({ try: operation, mapErr }) {
|
|
135
|
+
async function tryAsync({ try: operation, catch: catchFn }) {
|
|
216
136
|
try {
|
|
217
137
|
const data = await operation();
|
|
218
138
|
return Ok(data);
|
|
219
139
|
} catch (error) {
|
|
220
|
-
return
|
|
140
|
+
return catchFn(error);
|
|
221
141
|
}
|
|
222
142
|
}
|
|
223
143
|
/**
|
|
@@ -328,4 +248,4 @@ function resolve(value) {
|
|
|
328
248
|
|
|
329
249
|
//#endregion
|
|
330
250
|
export { Err, Ok, isErr, isOk, isResult, resolve, tryAsync, trySync, unwrap };
|
|
331
|
-
//# sourceMappingURL=result-
|
|
251
|
+
//# sourceMappingURL=result-B1iWFqM9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-BPrctj1f.js","names":["data: T","error: E","value: unknown","result: Result<T, E>","value: T | Result<T, E>"],"sources":["../src/result/result.ts"],"sourcesContent":["/**\n * Represents the successful outcome of an operation, encapsulating the success value.\n *\n * This is the 'Ok' variant of the `Result` type. It holds a `data` property\n * of type `T` (the success value) and an `error` property explicitly set to `null`,\n * signifying no error occurred.\n *\n * Use this type in conjunction with `Err<E>` and `Result<T, E>`.\n *\n * @template T - The type of the success value contained within.\n */\nexport type Ok<T> = { data: T; error: null };\n\n/**\n * Represents the failure outcome of an operation, encapsulating the error value.\n *\n * This is the 'Err' variant of the `Result` type. It holds an `error` property\n * of type `E` (the error value) and a `data` property explicitly set to `null`,\n * signifying that no success value is present due to the failure.\n *\n * Use this type in conjunction with `Ok<T>` and `Result<T, E>`.\n *\n * @template E - The type of the error value contained within.\n */\nexport type Err<E> = { error: E; data: null };\n\n/**\n * A type that represents the outcome of an operation that can either succeed or fail.\n *\n * `Result<T, E>` is a discriminated union type with two possible variants:\n * - `Ok<T>`: Represents a successful outcome, containing a `data` field with the success value of type `T`.\n * In this case, the `error` field is `null`.\n * - `Err<E>`: Represents a failure outcome, containing an `error` field with the error value of type `E`.\n * In this case, the `data` field is `null`.\n *\n * This type promotes explicit error handling by requiring developers to check\n * the variant of the `Result` before accessing its potential value or error.\n * It helps avoid runtime errors often associated with implicit error handling (e.g., relying on `try-catch` for all errors).\n *\n * @template T - The type of the success value if the operation is successful (held in `Ok<T>`).\n * @template E - The type of the error value if the operation fails (held in `Err<E>`).\n * @example\n * ```ts\n * function divide(numerator: number, denominator: number): Result<number, string> {\n * if (denominator === 0) {\n * return Err(\"Cannot divide by zero\");\n * }\n * return Ok(numerator / denominator);\n * }\n *\n * const result1 = divide(10, 2);\n * if (isOk(result1)) {\n * console.log(\"Success:\", result1.data); // Output: Success: 5\n * }\n *\n * const result2 = divide(10, 0);\n * if (isErr(result2)) {\n * console.error(\"Failure:\", result2.error); // Output: Failure: Cannot divide by zero\n * }\n * ```\n */\nexport type Result<T, E> = Ok<T> | Err<E>;\n\n/**\n * Constructs an `Ok<T>` variant, representing a successful outcome.\n *\n * This factory function creates the success variant of a `Result`.\n * It wraps the provided `data` (the success value) and ensures the `error` property is `null`.\n *\n * @template T - The type of the success value.\n * @param data - The success value to be wrapped in the `Ok` variant.\n * @returns An `Ok<T>` object with the provided data and `error` set to `null`.\n * @example\n * ```ts\n * const successfulResult = Ok(\"Operation completed successfully\");\n * // successfulResult is { data: \"Operation completed successfully\", error: null }\n * ```\n */\nexport const Ok = <T>(data: T): Ok<T> => ({ data, error: null });\n\n/**\n * Constructs an `Err<E>` variant, representing a failure outcome.\n *\n * This factory function creates the error variant of a `Result`.\n * It wraps the provided `error` (the error value) and ensures the `data` property is `null`.\n *\n * @template E - The type of the error value.\n * @param error - The error value to be wrapped in the `Err` variant. This value represents the specific error that occurred.\n * @returns An `Err<E>` object with the provided error and `data` set to `null`.\n * @example\n * ```ts\n * const failedResult = Err(new TypeError(\"Invalid input\"));\n * // failedResult is { error: TypeError(\"Invalid input\"), data: null }\n * ```\n */\nexport const Err = <E>(error: E): Err<E> => ({ error, data: null });\n\n/**\n * Utility type to extract the `Ok<T>` variant from a `Result<T, E>` union type.\n *\n * If `R` is a `Result` type (e.g., `Result<string, Error>`), this type will resolve\n * to `Ok<string>`. This can be useful in generic contexts or for type narrowing.\n *\n * @template R - The `Result<T, E>` union type from which to extract the `Ok<T>` variant.\n * Must extend `Result<unknown, unknown>`.\n */\nexport type ExtractOkFromResult<R extends Result<unknown, unknown>> = Extract<\n\tR,\n\t{ error: null }\n>;\n\n/**\n * Utility type to extract the `Err<E>` variant from a `Result<T, E>` union type.\n *\n * If `R` is a `Result` type (e.g., `Result<string, Error>`), this type will resolve\n * to `Err<Error>`. This can be useful in generic contexts or for type narrowing.\n *\n * @template R - The `Result<T, E>` union type from which to extract the `Err<E>` variant.\n * Must extend `Result<unknown, unknown>`.\n */\nexport type ExtractErrFromResult<R extends Result<unknown, unknown>> = Extract<\n\tR,\n\t{ data: null }\n>;\n\n/**\n * Utility type to extract the success value's type `T` from a `Result<T, E>` type.\n *\n * If `R` is an `Ok<T>` variant (or a `Result<T, E>` that could be an `Ok<T>`),\n * this type resolves to `T`. If `R` can only be an `Err<E>` variant, it resolves to `never`.\n * This is useful for obtaining the type of the `data` field when you know you have a success.\n *\n * @template R - The `Result<T, E>` type from which to extract the success value's type.\n * Must extend `Result<unknown, unknown>`.\n * @example\n * ```ts\n * type MyResult = Result<number, string>;\n * type SuccessValueType = UnwrapOk<MyResult>; // SuccessValueType is number\n *\n * type MyErrorResult = Err<string>;\n * type ErrorValueType = UnwrapOk<MyErrorResult>; // ErrorValueType is never\n * ```\n */\nexport type UnwrapOk<R extends Result<unknown, unknown>> = R extends Ok<infer U>\n\t? U\n\t: never;\n\n/**\n * Utility type to extract the error value's type `E` from a `Result<T, E>` type.\n *\n * If `R` is an `Err<E>` variant (or a `Result<T, E>` that could be an `Err<E>`),\n * this type resolves to `E`. If `R` can only be an `Ok<T>` variant, it resolves to `never`.\n * This is useful for obtaining the type of the `error` field when you know you have a failure.\n *\n * @template R - The `Result<T, E>` type from which to extract the error value's type.\n * Must extend `Result<unknown, unknown>`.\n * @example\n * ```ts\n * type MyResult = Result<number, string>;\n * type ErrorValueType = UnwrapErr<MyResult>; // ErrorValueType is string\n *\n * type MySuccessResult = Ok<number>;\n * type SuccessValueType = UnwrapErr<MySuccessResult>; // SuccessValueType is never\n * ```\n */\nexport type UnwrapErr<R extends Result<unknown, unknown>> = R extends Err<\n\tinfer E\n>\n\t? E\n\t: never;\n\n/**\n * Type guard to runtime check if an unknown value is a valid `Result<T, E>`.\n *\n * A value is considered a valid `Result` if:\n * 1. It is a non-null object.\n * 2. It has both `data` and `error` properties.\n * 3. At least one of the `data` or `error` channels is `null`. Both being `null` represents `Ok(null)`.\n *\n * This function does not validate the types of `data` or `error` beyond `null` checks.\n *\n * @template T - The expected type of the success value if the value is an `Ok` variant (defaults to `unknown`).\n * @template E - The expected type of the error value if the value is an `Err` variant (defaults to `unknown`).\n * @param value - The value to check.\n * @returns `true` if the value conforms to the `Result` structure, `false` otherwise.\n * If `true`, TypeScript's type system will narrow `value` to `Result<T, E>`.\n * @example\n * ```ts\n * declare const someValue: unknown;\n *\n * if (isResult<string, Error>(someValue)) {\n * // someValue is now typed as Result<string, Error>\n * if (isOk(someValue)) {\n * console.log(someValue.data); // string\n * } else {\n * console.error(someValue.error); // Error\n * }\n * }\n * ```\n */\nexport function isResult<T = unknown, E = unknown>(\n\tvalue: unknown,\n): value is Result<T, E> {\n\tconst isNonNullObject = typeof value === \"object\" && value !== null;\n\tif (!isNonNullObject) return false;\n\n\tconst hasDataProperty = \"data\" in value;\n\tconst hasErrorProperty = \"error\" in value;\n\tif (!hasDataProperty || !hasErrorProperty) return false;\n\n\tconst isNeitherNull = value.data !== null && value.error !== null;\n\tif (isNeitherNull) return false;\n\n\t// At least one channel is null (valid Result)\n\treturn true;\n}\n\n/**\n * Type guard to runtime check if a `Result<T, E>` is an `Ok<T>` variant.\n *\n * This function narrows the type of a `Result` to `Ok<T>` if it represents a successful outcome.\n * An `Ok<T>` variant is identified by its `error` property being `null`.\n *\n * @template T - The success value type.\n * @template E - The error value type.\n * @param result - The `Result<T, E>` to check.\n * @returns `true` if the `result` is an `Ok<T>` variant, `false` otherwise.\n * If `true`, TypeScript's type system will narrow `result` to `Ok<T>`.\n * @example\n * ```ts\n * declare const myResult: Result<number, string>;\n *\n * if (isOk(myResult)) {\n * // myResult is now typed as Ok<number>\n * console.log(\"Success value:\", myResult.data); // myResult.data is number\n * }\n * ```\n */\nexport function isOk<T, E>(result: Result<T, E>): result is Ok<T> {\n\treturn result.error === null;\n}\n\n/**\n * Type guard to runtime check if a `Result<T, E>` is an `Err<E>` variant.\n *\n * This function narrows the type of a `Result` to `Err<E>` if it represents a failure outcome.\n * An `Err<E>` variant is identified by its `error` property being non-`null` (and thus `data` being `null`).\n *\n * @template T - The success value type.\n * @template E - The error value type.\n * @param result - The `Result<T, E>` to check.\n * @returns `true` if the `result` is an `Err<E>` variant, `false` otherwise.\n * If `true`, TypeScript's type system will narrow `result` to `Err<E>`.\n * @example\n * ```ts\n * declare const myResult: Result<number, string>;\n *\n * if (isErr(myResult)) {\n * // myResult is now typed as Err<string>\n * console.error(\"Error value:\", myResult.error); // myResult.error is string\n * }\n * ```\n */\nexport function isErr<T, E>(result: Result<T, E>): result is Err<E> {\n\treturn result.error !== null; // Equivalent to result.data === null\n}\n\n/**\n * Executes a synchronous operation and wraps its outcome (success or failure) in a `Result<T, E>`.\n *\n * This function attempts to execute the `operation`.\n * - If `operation` completes successfully, its return value is wrapped in an `Ok<T>` variant.\n * - If `operation` throws an exception, the caught exception (of type `unknown`) is passed to\n * the `mapErr` function. `mapErr` is responsible for transforming this `unknown`\n * exception into an `Err<E>` variant containing a well-typed error value of type `E`.\n *\n * @template T - The type of the success value returned by the `operation` if it succeeds.\n * @template E - The type of the error value produced by `mapErr` if the `operation` fails.\n * @param options - An object containing the operation and error mapping function.\n * @param options.try - The synchronous operation to execute. This function is expected to return a value of type `T`.\n * @param options.mapErr - A function that takes the `unknown` exception caught from `options.try`\n * and transforms it into an `Err<E>` variant containing a specific error value of type `E`.\n * @returns A `Result<T, E>`: `Ok<T>` if `options.try` succeeds, or `Err<E>` if it throws and `options.mapErr` provides an error variant.\n * @example\n * ```ts\n * function parseJson(jsonString: string): Result<object, SyntaxError> {\n * return trySync({\n * try: () => JSON.parse(jsonString),\n * mapErr: (err: unknown) => {\n * if (err instanceof SyntaxError) return Err(err);\n * return Err(new SyntaxError(\"Unknown parsing error\"));\n * }\n * });\n * }\n *\n * const validResult = parseJson('{\"name\":\"Result\"}'); // Ok<{name: string}>\n * const invalidResult = parseJson('invalid json'); // Err<SyntaxError>\n *\n * if (isOk(validResult)) console.log(validResult.data);\n * if (isErr(invalidResult)) console.error(invalidResult.error.message);\n * ```\n */\nexport function trySync<T, E>({\n\ttry: operation,\n\tmapErr,\n}: {\n\ttry: () => T;\n\tmapErr: (error: unknown) => Err<E>;\n}): Result<T, E> {\n\ttry {\n\t\tconst data = operation();\n\t\treturn Ok(data);\n\t} catch (error) {\n\t\treturn mapErr(error);\n\t}\n}\n\n/**\n * Executes an asynchronous operation (returning a `Promise`) and wraps its outcome in a `Promise<Result<T, E>>`.\n *\n * This function attempts to execute the asynchronous `operation`.\n * - If the `Promise` returned by `operation` resolves successfully, its resolved value is wrapped in an `Ok<T>` variant.\n * - If the `Promise` returned by `operation` rejects, or if `operation` itself throws an exception synchronously,\n * the caught exception/rejection reason (of type `unknown`) is passed to the `mapErr` function.\n * `mapErr` is responsible for transforming this `unknown` error into an `Err<E>` variant containing\n * a well-typed error value of type `E`.\n *\n * The entire outcome (`Ok<T>` or `Err<E>`) is wrapped in a `Promise`.\n *\n * @template T - The type of the success value the `Promise` from `operation` resolves to.\n * @template E - The type of the error value produced by `mapErr` if the `operation` fails or rejects.\n * @param options - An object containing the asynchronous operation and error mapping function.\n * @param options.try - The asynchronous operation to execute. This function must return a `Promise<T>`.\n * @param options.mapErr - A function that takes the `unknown` exception/rejection reason caught from `options.try`\n * and transforms it into an `Err<E>` variant containing a specific error value of type `E`.\n * This function must return `Err<E>` directly.\n * @returns A `Promise` that resolves to a `Result<T, E>`: `Ok<T>` if `options.try`'s `Promise` resolves,\n * or `Err<E>` if it rejects/throws and `options.mapErr` provides an error variant.\n * @example\n * ```ts\n * async function fetchData(url: string): Promise<Result<Response, Error>> {\n * return tryAsync({\n * try: async () => fetch(url),\n * mapErr: (err: unknown) => {\n * if (err instanceof Error) return Err(err);\n * return Err(new Error(\"Network request failed\"));\n * }\n * });\n * }\n *\n * async function processData() {\n * const result = await fetchData(\"/api/data\");\n * if (isOk(result)) {\n * const response = result.data;\n * console.log(\"Data fetched:\", await response.json());\n * } else {\n * console.error(\"Fetch error:\", result.error.message);\n * }\n * }\n * processData();\n * ```\n */\nexport async function tryAsync<T, E>({\n\ttry: operation,\n\tmapErr,\n}: {\n\ttry: () => Promise<T>;\n\tmapErr: (error: unknown) => Err<E>;\n}): Promise<Result<T, E>> {\n\ttry {\n\t\tconst data = await operation();\n\t\treturn Ok(data);\n\t} catch (error) {\n\t\treturn mapErr(error);\n\t}\n}\n\n/**\n * Resolves a value that may or may not be wrapped in a `Result`, returning the final value.\n *\n * This function handles the common pattern where a value might be a `Result<T, E>` or a plain `T`:\n * - If `value` is an `Ok<T>` variant, returns the contained success value.\n * - If `value` is an `Err<E>` variant, throws the contained error value.\n * - If `value` is not a `Result` (i.e., it's already a plain value of type `T`),\n * returns it as-is.\n *\n * This is useful when working with APIs that might return either direct values or Results,\n * allowing you to normalize them to the actual value or propagate errors via throwing.\n *\n * Use `resolve` when the input might or might not be a Result.\n * Use `unwrap` when you know the input is definitely a Result.\n *\n * @template T - The type of the success value (if `value` is `Ok<T>`) or the type of the plain value.\n * @template E - The type of the error value (if `value` is `Err<E>`).\n * @param value - The value to resolve. Can be a `Result<T, E>` or a plain value of type `T`.\n * @returns The final value of type `T` if `value` is `Ok<T>` or if `value` is already a plain `T`.\n * @throws The error value `E` if `value` is an `Err<E>` variant.\n *\n * @example\n * ```ts\n * // Example with an Ok variant\n * const okResult = Ok(\"success data\");\n * const resolved = resolve(okResult); // \"success data\"\n *\n * // Example with an Err variant\n * const errResult = Err(new Error(\"failure\"));\n * try {\n * resolve(errResult);\n * } catch (e) {\n * console.error(e.message); // \"failure\"\n * }\n *\n * // Example with a plain value\n * const plainValue = \"plain data\";\n * const resolved = resolve(plainValue); // \"plain data\"\n *\n * // Example with a function that might return Result or plain value\n * declare function mightReturnResult(): string | Result<string, Error>;\n * const outcome = mightReturnResult();\n * try {\n * const finalValue = resolve(outcome); // handles both cases\n * console.log(\"Final value:\", finalValue);\n * } catch (e) {\n * console.error(\"Operation failed:\", e);\n * }\n * ```\n */\n/**\n * Unwraps a `Result<T, E>`, returning the success value or throwing the error.\n *\n * This function extracts the data from a `Result`:\n * - If the `Result` is an `Ok<T>` variant, returns the contained success value of type `T`.\n * - If the `Result` is an `Err<E>` variant, throws the contained error value of type `E`.\n *\n * Unlike `resolve`, this function expects the input to always be a `Result` type,\n * making it more direct for cases where you know you're working with a `Result`.\n *\n * @template T - The type of the success value contained in the `Ok<T>` variant.\n * @template E - The type of the error value contained in the `Err<E>` variant.\n * @param result - The `Result<T, E>` to unwrap.\n * @returns The success value of type `T` if the `Result` is `Ok<T>`.\n * @throws The error value of type `E` if the `Result` is `Err<E>`.\n *\n * @example\n * ```ts\n * // Example with an Ok variant\n * const okResult = Ok(\"success data\");\n * const value = unwrap(okResult); // \"success data\"\n *\n * // Example with an Err variant\n * const errResult = Err(new Error(\"something went wrong\"));\n * try {\n * unwrap(errResult);\n * } catch (error) {\n * console.error(error.message); // \"something went wrong\"\n * }\n *\n * // Usage in a function that returns Result\n * function divide(a: number, b: number): Result<number, string> {\n * if (b === 0) return Err(\"Division by zero\");\n * return Ok(a / b);\n * }\n *\n * try {\n * const result = unwrap(divide(10, 2)); // 5\n * console.log(\"Result:\", result);\n * } catch (error) {\n * console.error(\"Division failed:\", error);\n * }\n * ```\n */\nexport function unwrap<T, E>(result: Result<T, E>): T {\n\tif (isOk(result)) {\n\t\treturn result.data;\n\t}\n\tthrow result.error;\n}\n\nexport function resolve<T, E>(value: T | Result<T, E>): T {\n\tif (isResult<T, E>(value)) {\n\t\tif (isOk(value)) {\n\t\t\treturn value.data;\n\t\t}\n\t\t// If it's a Result and not Ok, it must be Err.\n\t\t// The type guard isResult<T,E>(value) and isOk(value) already refine the type.\n\t\t// So, 'value' here is known to be Err<E>.\n\t\tthrow value.error;\n\t}\n\n\t// If it's not a Result type, return the value as-is.\n\t// 'value' here is known to be of type T.\n\treturn value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8EA,MAAa,KAAK,CAAIA,UAAoB;CAAE;CAAM,OAAO;AAAM;;;;;;;;;;;;;;;;AAiB/D,MAAa,MAAM,CAAIC,WAAsB;CAAE;CAAO,MAAM;AAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGlE,SAAgB,SACfC,OACwB;CACxB,MAAM,yBAAyB,UAAU,YAAY,UAAU;AAC/D,MAAK,gBAAiB,QAAO;CAE7B,MAAM,kBAAkB,UAAU;CAClC,MAAM,mBAAmB,WAAW;AACpC,MAAK,oBAAoB,iBAAkB,QAAO;CAElD,MAAM,gBAAgB,MAAM,SAAS,QAAQ,MAAM,UAAU;AAC7D,KAAI,cAAe,QAAO;AAG1B,QAAO;AACP;;;;;;;;;;;;;;;;;;;;;;AAuBD,SAAgB,KAAWC,QAAuC;AACjE,QAAO,OAAO,UAAU;AACxB;;;;;;;;;;;;;;;;;;;;;;AAuBD,SAAgB,MAAYA,QAAwC;AACnE,QAAO,OAAO,UAAU;AACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCD,SAAgB,QAAc,EAC7B,KAAK,WACL,QAIA,EAAgB;AAChB,KAAI;EACH,MAAM,OAAO,WAAW;AACxB,SAAO,GAAG,KAAK;CACf,SAAQ,OAAO;AACf,SAAO,OAAO,MAAM;CACpB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CD,eAAsB,SAAe,EACpC,KAAK,WACL,QAIA,EAAyB;AACzB,KAAI;EACH,MAAM,OAAO,MAAM,WAAW;AAC9B,SAAO,GAAG,KAAK;CACf,SAAQ,OAAO;AACf,SAAO,OAAO,MAAM;CACpB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGD,SAAgB,OAAaA,QAAyB;AACrD,KAAI,KAAK,OAAO,CACf,QAAO,OAAO;AAEf,OAAM,OAAO;AACb;AAED,SAAgB,QAAcC,OAA4B;AACzD,KAAI,SAAe,MAAM,EAAE;AAC1B,MAAI,KAAK,MAAM,CACd,QAAO,MAAM;AAKd,QAAM,MAAM;CACZ;AAID,QAAO;AACP"}
|
|
1
|
+
{"version":3,"file":"result-B1iWFqM9.js","names":["data: T","error: E","value: unknown","result: Result<T, E>","value: T | Result<T, E>"],"sources":["../src/result/result.ts"],"sourcesContent":["/**\n * Represents the successful outcome of an operation, encapsulating the success value.\n *\n * This is the 'Ok' variant of the `Result` type. It holds a `data` property\n * of type `T` (the success value) and an `error` property explicitly set to `null`,\n * signifying no error occurred.\n *\n * Use this type in conjunction with `Err<E>` and `Result<T, E>`.\n *\n * @template T - The type of the success value contained within.\n */\nexport type Ok<T> = { data: T; error: null };\n\n/**\n * Represents the failure outcome of an operation, encapsulating the error value.\n *\n * This is the 'Err' variant of the `Result` type. It holds an `error` property\n * of type `E` (the error value) and a `data` property explicitly set to `null`,\n * signifying that no success value is present due to the failure.\n *\n * Use this type in conjunction with `Ok<T>` and `Result<T, E>`.\n *\n * @template E - The type of the error value contained within.\n */\nexport type Err<E> = { error: E; data: null };\n\n/**\n * A type that represents the outcome of an operation that can either succeed or fail.\n *\n * `Result<T, E>` is a discriminated union type with two possible variants:\n * - `Ok<T>`: Represents a successful outcome, containing a `data` field with the success value of type `T`.\n * In this case, the `error` field is `null`.\n * - `Err<E>`: Represents a failure outcome, containing an `error` field with the error value of type `E`.\n * In this case, the `data` field is `null`.\n *\n * This type promotes explicit error handling by requiring developers to check\n * the variant of the `Result` before accessing its potential value or error.\n * It helps avoid runtime errors often associated with implicit error handling (e.g., relying on `try-catch` for all errors).\n *\n * @template T - The type of the success value if the operation is successful (held in `Ok<T>`).\n * @template E - The type of the error value if the operation fails (held in `Err<E>`).\n * @example\n * ```ts\n * function divide(numerator: number, denominator: number): Result<number, string> {\n * if (denominator === 0) {\n * return Err(\"Cannot divide by zero\");\n * }\n * return Ok(numerator / denominator);\n * }\n *\n * const result1 = divide(10, 2);\n * if (isOk(result1)) {\n * console.log(\"Success:\", result1.data); // Output: Success: 5\n * }\n *\n * const result2 = divide(10, 0);\n * if (isErr(result2)) {\n * console.error(\"Failure:\", result2.error); // Output: Failure: Cannot divide by zero\n * }\n * ```\n */\nexport type Result<T, E> = Ok<T> | Err<E>;\n\n/**\n * Constructs an `Ok<T>` variant, representing a successful outcome.\n *\n * This factory function creates the success variant of a `Result`.\n * It wraps the provided `data` (the success value) and ensures the `error` property is `null`.\n *\n * @template T - The type of the success value.\n * @param data - The success value to be wrapped in the `Ok` variant.\n * @returns An `Ok<T>` object with the provided data and `error` set to `null`.\n * @example\n * ```ts\n * const successfulResult = Ok(\"Operation completed successfully\");\n * // successfulResult is { data: \"Operation completed successfully\", error: null }\n * ```\n */\nexport const Ok = <T>(data: T): Ok<T> => ({ data, error: null });\n\n/**\n * Constructs an `Err<E>` variant, representing a failure outcome.\n *\n * This factory function creates the error variant of a `Result`.\n * It wraps the provided `error` (the error value) and ensures the `data` property is `null`.\n *\n * @template E - The type of the error value.\n * @param error - The error value to be wrapped in the `Err` variant. This value represents the specific error that occurred.\n * @returns An `Err<E>` object with the provided error and `data` set to `null`.\n * @example\n * ```ts\n * const failedResult = Err(new TypeError(\"Invalid input\"));\n * // failedResult is { error: TypeError(\"Invalid input\"), data: null }\n * ```\n */\nexport const Err = <E>(error: E): Err<E> => ({ error, data: null });\n\n/**\n * Utility type to extract the `Ok<T>` variant from a `Result<T, E>` union type.\n *\n * If `R` is a `Result` type (e.g., `Result<string, Error>`), this type will resolve\n * to `Ok<string>`. This can be useful in generic contexts or for type narrowing.\n *\n * @template R - The `Result<T, E>` union type from which to extract the `Ok<T>` variant.\n * Must extend `Result<unknown, unknown>`.\n */\nexport type ExtractOkFromResult<R extends Result<unknown, unknown>> = Extract<\n\tR,\n\t{ error: null }\n>;\n\n/**\n * Utility type to extract the `Err<E>` variant from a `Result<T, E>` union type.\n *\n * If `R` is a `Result` type (e.g., `Result<string, Error>`), this type will resolve\n * to `Err<Error>`. This can be useful in generic contexts or for type narrowing.\n *\n * @template R - The `Result<T, E>` union type from which to extract the `Err<E>` variant.\n * Must extend `Result<unknown, unknown>`.\n */\nexport type ExtractErrFromResult<R extends Result<unknown, unknown>> = Extract<\n\tR,\n\t{ data: null }\n>;\n\n/**\n * Utility type to extract the success value's type `T` from a `Result<T, E>` type.\n *\n * If `R` is an `Ok<T>` variant (or a `Result<T, E>` that could be an `Ok<T>`),\n * this type resolves to `T`. If `R` can only be an `Err<E>` variant, it resolves to `never`.\n * This is useful for obtaining the type of the `data` field when you know you have a success.\n *\n * @template R - The `Result<T, E>` type from which to extract the success value's type.\n * Must extend `Result<unknown, unknown>`.\n * @example\n * ```ts\n * type MyResult = Result<number, string>;\n * type SuccessValueType = UnwrapOk<MyResult>; // SuccessValueType is number\n *\n * type MyErrorResult = Err<string>;\n * type ErrorValueType = UnwrapOk<MyErrorResult>; // ErrorValueType is never\n * ```\n */\nexport type UnwrapOk<R extends Result<unknown, unknown>> = R extends Ok<infer U>\n\t? U\n\t: never;\n\n/**\n * Utility type to extract the error value's type `E` from a `Result<T, E>` type.\n *\n * If `R` is an `Err<E>` variant (or a `Result<T, E>` that could be an `Err<E>`),\n * this type resolves to `E`. If `R` can only be an `Ok<T>` variant, it resolves to `never`.\n * This is useful for obtaining the type of the `error` field when you know you have a failure.\n *\n * @template R - The `Result<T, E>` type from which to extract the error value's type.\n * Must extend `Result<unknown, unknown>`.\n * @example\n * ```ts\n * type MyResult = Result<number, string>;\n * type ErrorValueType = UnwrapErr<MyResult>; // ErrorValueType is string\n *\n * type MySuccessResult = Ok<number>;\n * type SuccessValueType = UnwrapErr<MySuccessResult>; // SuccessValueType is never\n * ```\n */\nexport type UnwrapErr<R extends Result<unknown, unknown>> = R extends Err<\n\tinfer E\n>\n\t? E\n\t: never;\n\n/**\n * Type guard to runtime check if an unknown value is a valid `Result<T, E>`.\n *\n * A value is considered a valid `Result` if:\n * 1. It is a non-null object.\n * 2. It has both `data` and `error` properties.\n * 3. At least one of the `data` or `error` channels is `null`. Both being `null` represents `Ok(null)`.\n *\n * This function does not validate the types of `data` or `error` beyond `null` checks.\n *\n * @template T - The expected type of the success value if the value is an `Ok` variant (defaults to `unknown`).\n * @template E - The expected type of the error value if the value is an `Err` variant (defaults to `unknown`).\n * @param value - The value to check.\n * @returns `true` if the value conforms to the `Result` structure, `false` otherwise.\n * If `true`, TypeScript's type system will narrow `value` to `Result<T, E>`.\n * @example\n * ```ts\n * declare const someValue: unknown;\n *\n * if (isResult<string, Error>(someValue)) {\n * // someValue is now typed as Result<string, Error>\n * if (isOk(someValue)) {\n * console.log(someValue.data); // string\n * } else {\n * console.error(someValue.error); // Error\n * }\n * }\n * ```\n */\nexport function isResult<T = unknown, E = unknown>(\n\tvalue: unknown,\n): value is Result<T, E> {\n\tconst isNonNullObject = typeof value === \"object\" && value !== null;\n\tif (!isNonNullObject) return false;\n\n\tconst hasDataProperty = \"data\" in value;\n\tconst hasErrorProperty = \"error\" in value;\n\tif (!hasDataProperty || !hasErrorProperty) return false;\n\n\tconst isNeitherNull = value.data !== null && value.error !== null;\n\tif (isNeitherNull) return false;\n\n\t// At least one channel is null (valid Result)\n\treturn true;\n}\n\n/**\n * Type guard to runtime check if a `Result<T, E>` is an `Ok<T>` variant.\n *\n * This function narrows the type of a `Result` to `Ok<T>` if it represents a successful outcome.\n * An `Ok<T>` variant is identified by its `error` property being `null`.\n *\n * @template T - The success value type.\n * @template E - The error value type.\n * @param result - The `Result<T, E>` to check.\n * @returns `true` if the `result` is an `Ok<T>` variant, `false` otherwise.\n * If `true`, TypeScript's type system will narrow `result` to `Ok<T>`.\n * @example\n * ```ts\n * declare const myResult: Result<number, string>;\n *\n * if (isOk(myResult)) {\n * // myResult is now typed as Ok<number>\n * console.log(\"Success value:\", myResult.data); // myResult.data is number\n * }\n * ```\n */\nexport function isOk<T, E>(result: Result<T, E>): result is Ok<T> {\n\treturn result.error === null;\n}\n\n/**\n * Type guard to runtime check if a `Result<T, E>` is an `Err<E>` variant.\n *\n * This function narrows the type of a `Result` to `Err<E>` if it represents a failure outcome.\n * An `Err<E>` variant is identified by its `error` property being non-`null` (and thus `data` being `null`).\n *\n * @template T - The success value type.\n * @template E - The error value type.\n * @param result - The `Result<T, E>` to check.\n * @returns `true` if the `result` is an `Err<E>` variant, `false` otherwise.\n * If `true`, TypeScript's type system will narrow `result` to `Err<E>`.\n * @example\n * ```ts\n * declare const myResult: Result<number, string>;\n *\n * if (isErr(myResult)) {\n * // myResult is now typed as Err<string>\n * console.error(\"Error value:\", myResult.error); // myResult.error is string\n * }\n * ```\n */\nexport function isErr<T, E>(result: Result<T, E>): result is Err<E> {\n\treturn result.error !== null; // Equivalent to result.data === null\n}\n\n/**\n * Executes a synchronous operation and wraps its outcome in a Result type.\n *\n * This function attempts to execute the `try` operation:\n * - If the `try` operation completes successfully, its return value is wrapped in an `Ok<T>` variant.\n * - If the `try` operation throws an exception, the caught exception (of type `unknown`) is passed to\n * the `catch` function, which transforms it into either an `Ok<T>` (recovery) or `Err<E>` (propagation).\n *\n * The return type is automatically narrowed based on what your catch function returns:\n * - If catch always returns `Ok<T>`, the function returns `Ok<T>` (guaranteed success)\n * - If catch can return `Err<E>`, the function returns `Result<T, E>` (may succeed or fail)\n *\n * @template T - The success value type\n * @template E - The error value type (when catch can return errors)\n * @param options - Configuration object\n * @param options.try - The operation to execute\n * @param options.catch - Error handler that transforms caught exceptions into either `Ok<T>` (recovery) or `Err<E>` (propagation)\n * @returns `Ok<T>` if catch always returns Ok (recovery), otherwise `Result<T, E>` (propagation)\n *\n * @example\n * ```ts\n * // Returns Ok<string> - guaranteed success since catch always returns Ok\n * const alwaysOk = trySync({\n * try: () => JSON.parse(input),\n * catch: () => Ok(\"fallback\") // Always Ok<T>\n * });\n *\n * // Returns Result<object, string> - may fail since catch can return Err\n * const mayFail = trySync({\n * try: () => JSON.parse(input),\n * catch: (err) => Err(\"Parse failed\") // Returns Err<E>\n * });\n * ```\n */\nexport function trySync<T>(options: {\n\ttry: () => T;\n\tcatch: (error: unknown) => Ok<T>;\n}): Ok<T>;\n\nexport function trySync<T, E>(options: {\n\ttry: () => T;\n\tcatch: (error: unknown) => Err<E>;\n}): Result<T, E>;\n\nexport function trySync<T, E>({\n\ttry: operation,\n\tcatch: catchFn,\n}: {\n\ttry: () => T;\n\tcatch: (error: unknown) => Ok<T> | Err<E>;\n}): Ok<T> | Result<T, E> {\n\ttry {\n\t\tconst data = operation();\n\t\treturn Ok(data);\n\t} catch (error) {\n\t\treturn catchFn(error);\n\t}\n}\n\n/**\n * Executes an asynchronous operation and wraps its outcome in a Promise<Result>.\n *\n * This function attempts to execute the `try` operation:\n * - If the `try` operation resolves successfully, its resolved value is wrapped in an `Ok<T>` variant.\n * - If the `try` operation rejects or throws an exception, the caught error (of type `unknown`) is passed to\n * the `catch` function, which transforms it into either an `Ok<T>` (recovery) or `Err<E>` (propagation).\n *\n * The return type is automatically narrowed based on what your catch function returns:\n * - If catch always returns `Ok<T>`, the function returns `Promise<Ok<T>>` (guaranteed success)\n * - If catch can return `Err<E>`, the function returns `Promise<Result<T, E>>` (may succeed or fail)\n *\n * @template T - The success value type\n * @template E - The error value type (when catch can return errors)\n * @param options - Configuration object\n * @param options.try - The async operation to execute\n * @param options.catch - Error handler that transforms caught exceptions/rejections into either `Ok<T>` (recovery) or `Err<E>` (propagation)\n * @returns `Promise<Ok<T>>` if catch always returns Ok (recovery), otherwise `Promise<Result<T, E>>` (propagation)\n *\n * @example\n * ```ts\n * // Returns Promise<Ok<Response>> - guaranteed success since catch always returns Ok\n * const alwaysOk = tryAsync({\n * try: async () => fetch(url),\n * catch: () => Ok(new Response()) // Always Ok<T>\n * });\n *\n * // Returns Promise<Result<Response, Error>> - may fail since catch can return Err\n * const mayFail = tryAsync({\n * try: async () => fetch(url),\n * catch: (err) => Err(new Error(\"Fetch failed\")) // Returns Err<E>\n * });\n * ```\n */\nexport async function tryAsync<T>(options: {\n\ttry: () => Promise<T>;\n\tcatch: (error: unknown) => Ok<T>;\n}): Promise<Ok<T>>;\n\nexport async function tryAsync<T, E>(options: {\n\ttry: () => Promise<T>;\n\tcatch: (error: unknown) => Err<E>;\n}): Promise<Result<T, E>>;\n\nexport async function tryAsync<T, E>({\n\ttry: operation,\n\tcatch: catchFn,\n}: {\n\ttry: () => Promise<T>;\n\tcatch: (error: unknown) => Ok<T> | Err<E>;\n}): Promise<Ok<T> | Result<T, E>> {\n\ttry {\n\t\tconst data = await operation();\n\t\treturn Ok(data);\n\t} catch (error) {\n\t\treturn catchFn(error);\n\t}\n}\n\n/**\n * Resolves a value that may or may not be wrapped in a `Result`, returning the final value.\n *\n * This function handles the common pattern where a value might be a `Result<T, E>` or a plain `T`:\n * - If `value` is an `Ok<T>` variant, returns the contained success value.\n * - If `value` is an `Err<E>` variant, throws the contained error value.\n * - If `value` is not a `Result` (i.e., it's already a plain value of type `T`),\n * returns it as-is.\n *\n * This is useful when working with APIs that might return either direct values or Results,\n * allowing you to normalize them to the actual value or propagate errors via throwing.\n *\n * Use `resolve` when the input might or might not be a Result.\n * Use `unwrap` when you know the input is definitely a Result.\n *\n * @template T - The type of the success value (if `value` is `Ok<T>`) or the type of the plain value.\n * @template E - The type of the error value (if `value` is `Err<E>`).\n * @param value - The value to resolve. Can be a `Result<T, E>` or a plain value of type `T`.\n * @returns The final value of type `T` if `value` is `Ok<T>` or if `value` is already a plain `T`.\n * @throws The error value `E` if `value` is an `Err<E>` variant.\n *\n * @example\n * ```ts\n * // Example with an Ok variant\n * const okResult = Ok(\"success data\");\n * const resolved = resolve(okResult); // \"success data\"\n *\n * // Example with an Err variant\n * const errResult = Err(new Error(\"failure\"));\n * try {\n * resolve(errResult);\n * } catch (e) {\n * console.error(e.message); // \"failure\"\n * }\n *\n * // Example with a plain value\n * const plainValue = \"plain data\";\n * const resolved = resolve(plainValue); // \"plain data\"\n *\n * // Example with a function that might return Result or plain value\n * declare function mightReturnResult(): string | Result<string, Error>;\n * const outcome = mightReturnResult();\n * try {\n * const finalValue = resolve(outcome); // handles both cases\n * console.log(\"Final value:\", finalValue);\n * } catch (e) {\n * console.error(\"Operation failed:\", e);\n * }\n * ```\n */\n/**\n * Unwraps a `Result<T, E>`, returning the success value or throwing the error.\n *\n * This function extracts the data from a `Result`:\n * - If the `Result` is an `Ok<T>` variant, returns the contained success value of type `T`.\n * - If the `Result` is an `Err<E>` variant, throws the contained error value of type `E`.\n *\n * Unlike `resolve`, this function expects the input to always be a `Result` type,\n * making it more direct for cases where you know you're working with a `Result`.\n *\n * @template T - The type of the success value contained in the `Ok<T>` variant.\n * @template E - The type of the error value contained in the `Err<E>` variant.\n * @param result - The `Result<T, E>` to unwrap.\n * @returns The success value of type `T` if the `Result` is `Ok<T>`.\n * @throws The error value of type `E` if the `Result` is `Err<E>`.\n *\n * @example\n * ```ts\n * // Example with an Ok variant\n * const okResult = Ok(\"success data\");\n * const value = unwrap(okResult); // \"success data\"\n *\n * // Example with an Err variant\n * const errResult = Err(new Error(\"something went wrong\"));\n * try {\n * unwrap(errResult);\n * } catch (error) {\n * console.error(error.message); // \"something went wrong\"\n * }\n *\n * // Usage in a function that returns Result\n * function divide(a: number, b: number): Result<number, string> {\n * if (b === 0) return Err(\"Division by zero\");\n * return Ok(a / b);\n * }\n *\n * try {\n * const result = unwrap(divide(10, 2)); // 5\n * console.log(\"Result:\", result);\n * } catch (error) {\n * console.error(\"Division failed:\", error);\n * }\n * ```\n */\nexport function unwrap<T, E>(result: Result<T, E>): T {\n\tif (isOk(result)) {\n\t\treturn result.data;\n\t}\n\tthrow result.error;\n}\n\nexport function resolve<T, E>(value: T | Result<T, E>): T {\n\tif (isResult<T, E>(value)) {\n\t\tif (isOk(value)) {\n\t\t\treturn value.data;\n\t\t}\n\t\t// If it's a Result and not Ok, it must be Err.\n\t\t// The type guard isResult<T,E>(value) and isOk(value) already refine the type.\n\t\t// So, 'value' here is known to be Err<E>.\n\t\tthrow value.error;\n\t}\n\n\t// If it's not a Result type, return the value as-is.\n\t// 'value' here is known to be of type T.\n\treturn value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8EA,MAAa,KAAK,CAAIA,UAAoB;CAAE;CAAM,OAAO;AAAM;;;;;;;;;;;;;;;;AAiB/D,MAAa,MAAM,CAAIC,WAAsB;CAAE;CAAO,MAAM;AAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGlE,SAAgB,SACfC,OACwB;CACxB,MAAM,yBAAyB,UAAU,YAAY,UAAU;AAC/D,MAAK,gBAAiB,QAAO;CAE7B,MAAM,kBAAkB,UAAU;CAClC,MAAM,mBAAmB,WAAW;AACpC,MAAK,oBAAoB,iBAAkB,QAAO;CAElD,MAAM,gBAAgB,MAAM,SAAS,QAAQ,MAAM,UAAU;AAC7D,KAAI,cAAe,QAAO;AAG1B,QAAO;AACP;;;;;;;;;;;;;;;;;;;;;;AAuBD,SAAgB,KAAWC,QAAuC;AACjE,QAAO,OAAO,UAAU;AACxB;;;;;;;;;;;;;;;;;;;;;;AAuBD,SAAgB,MAAYA,QAAwC;AACnE,QAAO,OAAO,UAAU;AACxB;AA8CD,SAAgB,QAAc,EAC7B,KAAK,WACL,OAAO,SAIP,EAAwB;AACxB,KAAI;EACH,MAAM,OAAO,WAAW;AACxB,SAAO,GAAG,KAAK;CACf,SAAQ,OAAO;AACf,SAAO,QAAQ,MAAM;CACrB;AACD;AA8CD,eAAsB,SAAe,EACpC,KAAK,WACL,OAAO,SAIP,EAAiC;AACjC,KAAI;EACH,MAAM,OAAO,MAAM,WAAW;AAC9B,SAAO,GAAG,KAAK;CACf,SAAQ,OAAO;AACf,SAAO,QAAQ,MAAM;CACrB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGD,SAAgB,OAAaA,QAAyB;AACrD,KAAI,KAAK,OAAO,CACf,QAAO,OAAO;AAEf,OAAM,OAAO;AACb;AAED,SAAgB,QAAcC,OAA4B;AACzD,KAAI,SAAe,MAAM,EAAE;AAC1B,MAAI,KAAK,MAAM,CACd,QAAO,MAAM;AAKd,QAAM,MAAM;CACZ;AAID,QAAO;AACP"}
|
|
@@ -234,98 +234,88 @@ declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
|
|
|
234
234
|
*/
|
|
235
235
|
declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
|
|
236
236
|
/**
|
|
237
|
-
* Executes a synchronous operation and wraps its outcome
|
|
238
|
-
*
|
|
239
|
-
* This function attempts to execute the `operation
|
|
240
|
-
* - If `
|
|
241
|
-
* - If `
|
|
242
|
-
* the `
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* @param options - An object containing the operation and error mapping function.
|
|
248
|
-
* @param options.try - The synchronous operation to execute. This function is expected to return a value of type `T`.
|
|
249
|
-
* @param options.mapErr - A function that takes the `unknown` exception caught from `options.try`
|
|
250
|
-
* and transforms it into an `Err<E>` variant containing a specific error value of type `E`.
|
|
251
|
-
* @returns A `Result<T, E>`: `Ok<T>` if `options.try` succeeds, or `Err<E>` if it throws and `options.mapErr` provides an error variant.
|
|
252
|
-
* @example
|
|
253
|
-
* ```ts
|
|
254
|
-
* function parseJson(jsonString: string): Result<object, SyntaxError> {
|
|
255
|
-
* return trySync({
|
|
256
|
-
* try: () => JSON.parse(jsonString),
|
|
257
|
-
* mapErr: (err: unknown) => {
|
|
258
|
-
* if (err instanceof SyntaxError) return Err(err);
|
|
259
|
-
* return Err(new SyntaxError("Unknown parsing error"));
|
|
260
|
-
* }
|
|
261
|
-
* });
|
|
262
|
-
* }
|
|
237
|
+
* Executes a synchronous operation and wraps its outcome in a Result type.
|
|
238
|
+
*
|
|
239
|
+
* This function attempts to execute the `try` operation:
|
|
240
|
+
* - If the `try` operation completes successfully, its return value is wrapped in an `Ok<T>` variant.
|
|
241
|
+
* - If the `try` operation throws an exception, the caught exception (of type `unknown`) is passed to
|
|
242
|
+
* the `catch` function, which transforms it into either an `Ok<T>` (recovery) or `Err<E>` (propagation).
|
|
243
|
+
*
|
|
244
|
+
* The return type is automatically narrowed based on what your catch function returns:
|
|
245
|
+
* - If catch always returns `Ok<T>`, the function returns `Ok<T>` (guaranteed success)
|
|
246
|
+
* - If catch can return `Err<E>`, the function returns `Result<T, E>` (may succeed or fail)
|
|
263
247
|
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
248
|
+
* @template T - The success value type
|
|
249
|
+
* @template E - The error value type (when catch can return errors)
|
|
250
|
+
* @param options - Configuration object
|
|
251
|
+
* @param options.try - The operation to execute
|
|
252
|
+
* @param options.catch - Error handler that transforms caught exceptions into either `Ok<T>` (recovery) or `Err<E>` (propagation)
|
|
253
|
+
* @returns `Ok<T>` if catch always returns Ok (recovery), otherwise `Result<T, E>` (propagation)
|
|
266
254
|
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* // Returns Ok<string> - guaranteed success since catch always returns Ok
|
|
258
|
+
* const alwaysOk = trySync({
|
|
259
|
+
* try: () => JSON.parse(input),
|
|
260
|
+
* catch: () => Ok("fallback") // Always Ok<T>
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* // Returns Result<object, string> - may fail since catch can return Err
|
|
264
|
+
* const mayFail = trySync({
|
|
265
|
+
* try: () => JSON.parse(input),
|
|
266
|
+
* catch: (err) => Err("Parse failed") // Returns Err<E>
|
|
267
|
+
* });
|
|
269
268
|
* ```
|
|
270
269
|
*/
|
|
271
|
-
declare function trySync<T
|
|
272
|
-
try: operation,
|
|
273
|
-
mapErr
|
|
274
|
-
}: {
|
|
270
|
+
declare function trySync<T>(options: {
|
|
275
271
|
try: () => T;
|
|
276
|
-
|
|
272
|
+
catch: (error: unknown) => Ok<T>;
|
|
273
|
+
}): Ok<T>;
|
|
274
|
+
declare function trySync<T, E>(options: {
|
|
275
|
+
try: () => T;
|
|
276
|
+
catch: (error: unknown) => Err<E>;
|
|
277
277
|
}): Result<T, E>;
|
|
278
278
|
/**
|
|
279
|
-
* Executes an asynchronous operation
|
|
280
|
-
*
|
|
281
|
-
* This function attempts to execute the
|
|
282
|
-
* - If the `
|
|
283
|
-
* - If the `
|
|
284
|
-
* the
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
* @template T - The
|
|
291
|
-
* @template E - The
|
|
292
|
-
* @param options -
|
|
293
|
-
* @param options.try - The
|
|
294
|
-
* @param options.
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* @returns A `Promise` that resolves to a `Result<T, E>`: `Ok<T>` if `options.try`'s `Promise` resolves,
|
|
298
|
-
* or `Err<E>` if it rejects/throws and `options.mapErr` provides an error variant.
|
|
279
|
+
* Executes an asynchronous operation and wraps its outcome in a Promise<Result>.
|
|
280
|
+
*
|
|
281
|
+
* This function attempts to execute the `try` operation:
|
|
282
|
+
* - If the `try` operation resolves successfully, its resolved value is wrapped in an `Ok<T>` variant.
|
|
283
|
+
* - If the `try` operation rejects or throws an exception, the caught error (of type `unknown`) is passed to
|
|
284
|
+
* the `catch` function, which transforms it into either an `Ok<T>` (recovery) or `Err<E>` (propagation).
|
|
285
|
+
*
|
|
286
|
+
* The return type is automatically narrowed based on what your catch function returns:
|
|
287
|
+
* - If catch always returns `Ok<T>`, the function returns `Promise<Ok<T>>` (guaranteed success)
|
|
288
|
+
* - If catch can return `Err<E>`, the function returns `Promise<Result<T, E>>` (may succeed or fail)
|
|
289
|
+
*
|
|
290
|
+
* @template T - The success value type
|
|
291
|
+
* @template E - The error value type (when catch can return errors)
|
|
292
|
+
* @param options - Configuration object
|
|
293
|
+
* @param options.try - The async operation to execute
|
|
294
|
+
* @param options.catch - Error handler that transforms caught exceptions/rejections into either `Ok<T>` (recovery) or `Err<E>` (propagation)
|
|
295
|
+
* @returns `Promise<Ok<T>>` if catch always returns Ok (recovery), otherwise `Promise<Result<T, E>>` (propagation)
|
|
296
|
+
*
|
|
299
297
|
* @example
|
|
300
298
|
* ```ts
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
* const result = await fetchData("/api/data");
|
|
313
|
-
* if (isOk(result)) {
|
|
314
|
-
* const response = result.data;
|
|
315
|
-
* console.log("Data fetched:", await response.json());
|
|
316
|
-
* } else {
|
|
317
|
-
* console.error("Fetch error:", result.error.message);
|
|
318
|
-
* }
|
|
319
|
-
* }
|
|
320
|
-
* processData();
|
|
299
|
+
* // Returns Promise<Ok<Response>> - guaranteed success since catch always returns Ok
|
|
300
|
+
* const alwaysOk = tryAsync({
|
|
301
|
+
* try: async () => fetch(url),
|
|
302
|
+
* catch: () => Ok(new Response()) // Always Ok<T>
|
|
303
|
+
* });
|
|
304
|
+
*
|
|
305
|
+
* // Returns Promise<Result<Response, Error>> - may fail since catch can return Err
|
|
306
|
+
* const mayFail = tryAsync({
|
|
307
|
+
* try: async () => fetch(url),
|
|
308
|
+
* catch: (err) => Err(new Error("Fetch failed")) // Returns Err<E>
|
|
309
|
+
* });
|
|
321
310
|
* ```
|
|
322
311
|
*/
|
|
323
|
-
declare function tryAsync<T
|
|
324
|
-
try:
|
|
325
|
-
|
|
326
|
-
}:
|
|
312
|
+
declare function tryAsync<T>(options: {
|
|
313
|
+
try: () => Promise<T>;
|
|
314
|
+
catch: (error: unknown) => Ok<T>;
|
|
315
|
+
}): Promise<Ok<T>>;
|
|
316
|
+
declare function tryAsync<T, E>(options: {
|
|
327
317
|
try: () => Promise<T>;
|
|
328
|
-
|
|
318
|
+
catch: (error: unknown) => Err<E>;
|
|
329
319
|
}): Promise<Result<T, E>>;
|
|
330
320
|
/**
|
|
331
321
|
* Resolves a value that may or may not be wrapped in a `Result`, returning the final value.
|
|
@@ -426,4 +416,4 @@ declare function resolve<T, E>(value: T | Result<T, E>): T;
|
|
|
426
416
|
//# sourceMappingURL=result.d.ts.map
|
|
427
417
|
//#endregion
|
|
428
418
|
export { Err, ExtractErrFromResult, ExtractOkFromResult, Ok, Result, UnwrapErr, UnwrapOk, isErr, isOk, isResult, resolve, tryAsync, trySync, unwrap };
|
|
429
|
-
//# sourceMappingURL=result-
|
|
419
|
+
//# sourceMappingURL=result-DRq8PMRe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-DRq8PMRe.d.ts","names":[],"sources":["../src/result/result.ts"],"sourcesContent":[],"mappings":";;AAWA;AAaA;AAqCA;;;;;;AAAsC;AAiBtC;AAAgE,KAnEpD,EAmEoD,CAAA,CAAA,CAAA,GAAA;EAAA,IAApC,EAnEA,CAmEA;EAAC,KAAM,EAAA,IAAA;CAAC;AAAF;AAiBlC;;;;;AAAqC;AAWrC;;;;AAAsE,KAlF1D,GAkF0D,CAAA,CAAA,CAAA,GAAA;EAAO,KAAA,EAlF/C,CAkF+C;EAcjE,IAAA,EAAA,IAAA;CAAoB;;;;AAA8C;AAuB9E;;;;;;AACI;AAqBJ;;;;;;AAGI;AAgCJ;;;;;AAEkB;AAoClB;;;;;;;AAA8D;AAyB9D;;;AAA8C,KA1MlC,MA0MkC,CAAA,CAAA,EAAA,CAAA,CAAA,GA1MnB,EA0MmB,CA1MhB,CA0MgB,CAAA,GA1MX,GA0MW,CA1MP,CA0MO,CAAA;;;;AAAkB;AAsChE;;;;;;;AAGM;AAEN;;;AAEgC,cAtOnB,EAsOmB,EAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAtOJ,CAsOI,EAAA,GAtOA,EAsOA,CAtOG,CAsOH,CAAA;;;;;AACtB;AAmDV;;;;;;;;;AAGW;AAEW,cA9QT,GA8QiB,EAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EA9QA,CA8QA,EAAA,GA9QI,GA8QJ,CA9QQ,CA8QR,CAAA;;;;;;;;;;AAGnB,KAtQC,mBAsQD,CAAA,UAtQ+B,MAsQ/B,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,GAtQ2D,OAsQ3D,CArQV,CAqQU,EAAA;EA+GK,KAAA,EAAA,IAAM;CAAA,CAAA;;;;;AAA+B;AAOrD;;;;AAAmD,KA9WvC,oBA8WuC,CAAA,UA9WR,MA8WQ,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,GA9WoB,OA8WpB,CA7WlD,CA6WkD,EAAA;EAAC,IAAX,EAAA,IAAA;CAAM,CAAA;AAAU;;;;;;;;;;;;;;;;;;KAvV7C,mBAAmB,4BAA4B,UAAU,cAClE;;;;;;;;;;;;;;;;;;;KAqBS,oBAAoB,4BAA4B,UAAU,eAGnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgCa,6DAEJ,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;iBAoCN,mBAAmB,OAAO,GAAG,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;iBAyB/C,oBAAoB,OAAO,GAAG,eAAe,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCjD;aACJ;6BACgB,GAAG;IAC3B,GAAG;iBAES;aACJ;6BACgB,IAAI;IAC5B,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmDQ;aACV,QAAQ;6BACQ,GAAG;IAC3B,QAAQ,GAAG;iBAEO;aACV,QAAQ;6BACQ,IAAI;IAC5B,QAAQ,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+GN,qBAAqB,OAAO,GAAG,KAAK;iBAOpC,qBAAqB,IAAI,OAAO,GAAG,KAAK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isOk } from "./result-
|
|
1
|
+
import { isOk } from "./result-B1iWFqM9.js";
|
|
2
2
|
|
|
3
3
|
//#region src/result/utils.ts
|
|
4
4
|
/**
|
|
@@ -27,4 +27,4 @@ function partitionResults(results) {
|
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
29
|
export { partitionResults };
|
|
30
|
-
//# sourceMappingURL=result-
|
|
30
|
+
//# sourceMappingURL=result-DfuKgZo9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-
|
|
1
|
+
{"version":3,"file":"result-DfuKgZo9.js","names":["results: Result<T, E>[]"],"sources":["../src/result/utils.ts"],"sourcesContent":["import type { Err, Ok, Result } from \"./result.js\";\nimport { isOk } from \"./result.js\";\n\n/**\n * Partitions an array of Result objects into two separate arrays based on their status.\n *\n * @template T - The success type\n * @template E - The error type\n * @param results - An array of Result objects to partition\n * @returns An object containing two arrays:\n * - `oks`: Array of successful Result objects (Ok<T>[])\n * - `errs`: Array of error Result objects (Err<E>[])\n *\n * @example\n * const results = [Ok(1), Err(\"error\"), Ok(2)];\n * const { oks, errs } = partitionResults(results);\n * // oks = [Ok(1), Ok(2)]\n * // errs = [Err(\"error\")]\n */\nexport function partitionResults<T, E>(results: Result<T, E>[]) {\n\treturn {\n\t\toks: [],\n\t\terrs: [],\n\t\t...Object.groupBy(results, (result) => (isOk(result) ? \"oks\" : \"errs\")),\n\t} as { oks: Ok<T>[]; errs: Err<E>[] };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAuBA,SAAyB;AAC/D,QAAO;EACN,KAAK,CAAE;EACP,MAAM,CAAE;EACR,GAAG,OAAO,QAAQ,SAAS,CAAC,WAAY,KAAK,OAAO,GAAG,QAAQ,OAAQ;CACvE;AACD"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-DucAuR8u.d.ts","names":[],"sources":["../src/result/result.ts"],"sourcesContent":[],"mappings":";;AAWA;AAaA;AAqCA;;;;;;AAAsC;AAiBtC;AAAgE,KAnEpD,EAmEoD,CAAA,CAAA,CAAA,GAAA;EAAA,IAApC,EAnEA,CAmEA;EAAC,KAAM,EAAA,IAAA;CAAC;AAAF;AAiBlC;;;;;AAAqC;AAWrC;;;;AAAsE,KAlF1D,GAkF0D,CAAA,CAAA,CAAA,GAAA;EAAO,KAAA,EAlF/C,CAkF+C;EAcjE,IAAA,EAAA,IAAA;CAAoB;;;;AAA8C;AAuB9E;;;;;;AACI;AAqBJ;;;;;;AAGI;AAgCJ;;;;;AAEkB;AAoClB;;;;;;;AAA8D;AAyB9D;;;AAA8C,KA1MlC,MA0MkC,CAAA,CAAA,EAAA,CAAA,CAAA,GA1MnB,EA0MmB,CA1MhB,CA0MgB,CAAA,GA1MX,GA0MW,CA1MP,CA0MO,CAAA;;;;AAAkB;AAuChE;;;;;;;;;;AAMU;AAsDY,cA5RT,EA4RiB,EAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EA5RF,CA4RE,EAAA,GA5RE,EA4RF,CA5RK,CA4RL,CAAA;;;;;;;;;;;;AAMnB;AAuGX;;;AAA+C,cAxXlC,GAwXkC,EAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAxXjB,CAwXiB,EAAA,GAxXb,GAwXa,CAxXT,CAwXS,CAAA;;;AAAM;AAOrD;;;;;;AAAwD,KApX5C,mBAoX4C,CAAA,UApXd,MAoXc,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,GApXc,OAoXd,CAnXvD,CAmXuD,EAAA;EAAC,KAAA,EAAA,IAAA;;;;;;;;;;;KAtW7C,+BAA+B,4BAA4B,QACtE;;;;;;;;;;;;;;;;;;;;;KAsBW,mBAAmB,4BAA4B,UAAU,cAClE;;;;;;;;;;;;;;;;;;;KAqBS,oBAAoB,4BAA4B,UAAU,eAGnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgCa,6DAEJ,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;iBAoCN,mBAAmB,OAAO,GAAG,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;iBAyB/C,oBAAoB,OAAO,GAAG,eAAe,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuCjD;OACV;;;aAGM;8BACiB,IAAI;IAC7B,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDQ;OAChB;;;aAGM,QAAQ;8BACS,IAAI;IAC7B,QAAQ,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuGN,qBAAqB,OAAO,GAAG,KAAK;iBAOpC,qBAAqB,IAAI,OAAO,GAAG,KAAK"}
|