@mkvlrn/result 1.1.2 → 1.1.4
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/build/index.d.ts +3 -0
- package/build/index.js +3 -3
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Result type to represent the outcome of an operation.
|
|
3
3
|
* It can either be a success with a value or an error with an error message.
|
|
4
4
|
* This is a generic type that can be used with any type of value and error.
|
|
5
|
+
*
|
|
6
|
+
* It is also an alias object containing the success and error functions to
|
|
7
|
+
* make it easier to create Result objects.
|
|
5
8
|
*/
|
|
6
9
|
export type Result<T, E = Error> = {
|
|
7
10
|
readonly ok: true;
|
package/build/index.js
CHANGED
|
@@ -7,9 +7,9 @@ export const Result = {
|
|
|
7
7
|
*/
|
|
8
8
|
success: (value) => ({ ok: true, value: value }),
|
|
9
9
|
/**
|
|
10
|
-
* Creates
|
|
11
|
-
* @param
|
|
12
|
-
* @returns A Result object representing
|
|
10
|
+
* Creates an error Result with the given error.
|
|
11
|
+
* @param error The error value
|
|
12
|
+
* @returns A Result object representing error
|
|
13
13
|
*/
|
|
14
14
|
error: (error) => ({ ok: false, error: error }),
|
|
15
15
|
};
|