@mkvlrn/result 4.0.2 → 4.0.3
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/.turbo/turbo-build.log +10 -0
- package/CHANGELOG.md +6 -0
- package/build/index.d.ts +35 -0
- package/build/index.js +8 -0
- package/build/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @mkvlrn/result@4.0.3 build
|
|
4
|
+
> vite build
|
|
5
|
+
|
|
6
|
+
[1G[0K[36mvite v7.0.6 [32mbuilding for production...[36m[39m
|
|
7
|
+
[2K[1Gtransforming (1) [2msrc/index.ts[22m[2K[1G[32m✓[39m 1 modules transformed.
|
|
8
|
+
[2K[1Grendering chunks (1)...[2K[1G[2K[1Gcomputing gzip size (0)...[2K[1Gcomputing gzip size (1)...[2K[1G[2mbuild/[22m[36mindex.js [39m[1m[2m0.15 kB[22m[1m[22m[2m │ gzip: 0.13 kB[22m[2m │ map: 1.52 kB[22m
|
|
9
|
+
[32m✓ built in 409ms[39m
|
|
10
|
+
[1G[0Kâ ™[1G[0K
|
package/CHANGELOG.md
CHANGED
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result type to represent the outcome of an operation.
|
|
3
|
+
* It can either be a success with a value or an error.
|
|
4
|
+
* This is a generic type that can be used with any type of value and error (should extend Error).
|
|
5
|
+
*
|
|
6
|
+
* It is also an alias object containing the ok and error functions to
|
|
7
|
+
* make it easier to create Result objects.
|
|
8
|
+
*/
|
|
9
|
+
export type Result<T, E extends Error> = {
|
|
10
|
+
readonly error: undefined;
|
|
11
|
+
readonly value: T;
|
|
12
|
+
} | {
|
|
13
|
+
readonly error: E;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Async version of Result type that wraps a Result in a Promise.
|
|
17
|
+
*/
|
|
18
|
+
export type AsyncResult<T, E extends Error> = Promise<Result<T, E>>;
|
|
19
|
+
/**
|
|
20
|
+
* Result utility functions for creating Result objects.
|
|
21
|
+
*/
|
|
22
|
+
export declare const R: {
|
|
23
|
+
/**
|
|
24
|
+
* Creates a successful Result with the given value.
|
|
25
|
+
* @param value The success value
|
|
26
|
+
* @returns A Result object representing success
|
|
27
|
+
*/
|
|
28
|
+
ok<T>(value: T): Result<T, never>;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an error Result with the given error.
|
|
31
|
+
* @param error The error value
|
|
32
|
+
* @returns A Result object representing error
|
|
33
|
+
*/
|
|
34
|
+
error<E extends Error>(error: E): Result<never, E>;
|
|
35
|
+
};
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Result type to represent the outcome of an operation.\n * It can either be a success with a value or an error.\n * This is a generic type that can be used with any type of value and error (should extend Error).\n *\n * It is also an alias object containing the ok and error functions to\n * make it easier to create Result objects.\n */\nexport type Result<T, E extends Error> =\n | { readonly error: undefined; readonly value: T }\n | { readonly error: E };\n\n/**\n * Async version of Result type that wraps a Result in a Promise.\n */\nexport type AsyncResult<T, E extends Error> = Promise<Result<T, E>>;\n\n/**\n * Result utility functions for creating Result objects.\n */\nexport const R: {\n /**\n * Creates a successful Result with the given value.\n * @param value The success value\n * @returns A Result object representing success\n */\n ok<T>(value: T): Result<T, never>;\n /**\n * Creates an error Result with the given error.\n * @param error The error value\n * @returns A Result object representing error\n */\n error<E extends Error>(error: E): Result<never, E>;\n} = {\n ok: <T>(value: T): Result<T, never> => ({ error: undefined, value }),\n error: <E extends Error>(error: E): Result<never, E> => ({ error }),\n};\n"],"names":["R","value","error"],"mappings":"AAoBO,MAAMA,IAaT;AAAA,EACF,IAAI,CAAIC,OAAgC,EAAE,OAAO,QAAW,OAAAA,EAAA;AAAA,EAC5D,OAAO,CAAkBC,OAAgC,EAAE,OAAAA,EAAA;AAC7D;"}
|