@mkvlrn/result 5.0.4 → 5.0.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Mike Valeriano <mkvlrn@gmail.com>
3
+ Copyright (c) 2026 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/build/index.d.ts CHANGED
@@ -1,12 +1,4 @@
1
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
2
  type Result<T, E extends Error> = {
11
3
  readonly isError: false;
12
4
  readonly isOk: true;
@@ -16,21 +8,9 @@ type Result<T, E extends Error> = {
16
8
  readonly isOk: false;
17
9
  readonly error: E;
18
10
  };
19
- /**
20
- * Async version of Result type that wraps a Result in a Promise.
21
- */
22
11
  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
12
  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
13
  declare function err<E extends Error>(error: E): Result<never, E>;
35
14
  //#endregion
36
- export { AsyncResult, Result, err, ok };
15
+ export { AsyncResult, Result, err, ok };
16
+ //# sourceMappingURL=index.d.ts.map
package/build/index.js CHANGED
@@ -1 +1,29 @@
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};
1
+ //#region src/index.ts
2
+ /**
3
+ * Creates a successful Result with the given value.
4
+ * @param value The success value
5
+ * @returns A Result object representing success
6
+ */
7
+ function ok(value) {
8
+ return {
9
+ isError: false,
10
+ isOk: true,
11
+ value
12
+ };
13
+ }
14
+ /**
15
+ * Creates an error Result with the given error.
16
+ * @param error The error value
17
+ * @returns A Result object representing error
18
+ */
19
+ function err(error) {
20
+ return {
21
+ isError: true,
22
+ isOk: false,
23
+ error
24
+ };
25
+ }
26
+
27
+ //#endregion
28
+ export { err, ok };
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"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 isError: false; readonly isOk: true; readonly value: T }\n | { readonly isError: true; readonly isOk: false; 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 * Creates a successful Result with the given value.\n * @param value The success value\n * @returns A Result object representing success\n */\nexport function ok<T>(value: T): Result<T, never> {\n return { isError: false, isOk: true, value };\n}\n\n/**\n * Creates an error Result with the given error.\n * @param error The error value\n * @returns A Result object representing error\n */\nexport function err<E extends Error>(error: E): Result<never, E> {\n return { isError: true, isOk: false, error };\n}\n"],"mappings":";;;;;;AAsBA,SAAgB,GAAM,OAA4B;AAChD,QAAO;EAAE,SAAS;EAAO,MAAM;EAAM;EAAO;;;;;;;AAQ9C,SAAgB,IAAqB,OAA4B;AAC/D,QAAO;EAAE,SAAS;EAAM,MAAM;EAAO;EAAO"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mkvlrn/result",
3
3
  "description": "Simple Result type/pattern for TypeScript",
4
- "version": "5.0.4",
4
+ "version": "5.0.6",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "author": "Mike Valeriano <mkvlrn@proton.me>",
7
+ "author": "Mike Valeriano <mkvlrn@gmail.com>",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git@github.com:mkvlrn/tools"
@@ -20,25 +20,23 @@
20
20
  "files": [
21
21
  "build"
22
22
  ],
23
+ "imports": {
24
+ "#*": "./src/*.ts"
25
+ },
23
26
  "exports": {
24
27
  "types": "./build/index.d.ts",
25
28
  "default": "./build/index.js"
26
29
  },
27
30
  "devDependencies": {
28
- "@types/node": "^25.0.3",
31
+ "@types/node": "^25.2.0",
29
32
  "lint-staged": "^16.2.7",
30
- "rimraf": "^6.1.2",
31
33
  "tsc-files": "^1.1.4",
32
- "tsdown": "^0.18.3",
33
- "tsx": "^4.21.0",
34
+ "tsdown": "0.20.1",
34
35
  "typescript": "^5.9.3",
35
- "vite-tsconfig-paths": "^6.0.3"
36
- },
37
- "dependencies": {
38
- "vitest": "^4.0.16"
36
+ "vitest": "^4.0.18"
39
37
  },
40
38
  "scripts": {
41
39
  "build": "tsdown",
42
- "typecheck": "tsc"
40
+ "typecheck": "tsc --noEmit"
43
41
  }
44
42
  }