@mkvlrn/result 5.0.2 → 5.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/LICENSE +1 -1
- package/package.json +2 -2
- package/build/index.d.ts +0 -36
- package/build/index.js +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025 Mike Valeriano <mkvlrn@
|
|
3
|
+
Copyright (c) 2025 Mike Valeriano <mkvlrn@gmail.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mkvlrn/result",
|
|
3
3
|
"description": "Simple Result type/pattern for TypeScript",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Mike Valeriano <mkvlrn@proton.me>",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"lint-staged": "^16.2.7",
|
|
30
30
|
"rimraf": "^6.1.2",
|
|
31
31
|
"tsc-files": "^1.1.4",
|
|
32
|
-
"tsdown": "^0.18.
|
|
32
|
+
"tsdown": "^0.18.3",
|
|
33
33
|
"tsx": "^4.21.0",
|
|
34
34
|
"typescript": "^5.9.3",
|
|
35
35
|
"vite-tsconfig-paths": "^6.0.3"
|
package/build/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//#region src/index.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Result type to represent the outcome of an operation.
|
|
4
|
-
* It can either be a success with a value or an error.
|
|
5
|
-
* This is a generic type that can be used with any type of value and error (should extend Error).
|
|
6
|
-
*
|
|
7
|
-
* It is also an alias object containing the ok and error functions to
|
|
8
|
-
* make it easier to create Result objects.
|
|
9
|
-
*/
|
|
10
|
-
type Result<T, E extends Error> = {
|
|
11
|
-
readonly isError: false;
|
|
12
|
-
readonly isOk: true;
|
|
13
|
-
readonly value: T;
|
|
14
|
-
} | {
|
|
15
|
-
readonly isError: true;
|
|
16
|
-
readonly isOk: false;
|
|
17
|
-
readonly error: E;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Async version of Result type that wraps a Result in a Promise.
|
|
21
|
-
*/
|
|
22
|
-
type AsyncResult<T, E extends Error> = Promise<Result<T, E>>;
|
|
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
|
-
declare function 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
|
-
declare function err<E extends Error>(error: E): Result<never, E>;
|
|
35
|
-
//#endregion
|
|
36
|
-
export { AsyncResult, Result, err, ok };
|
package/build/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){return{isError:!1,isOk:!0,value:e}}function t(e){return{isError:!0,isOk:!1,error:e}}export{t as err,e as ok};
|