@mkvlrn/result 1.1.4 → 2.0.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/build/index.d.ts CHANGED
@@ -3,17 +3,16 @@
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
5
  *
6
- * It is also an alias object containing the success and error functions to
6
+ * It is also an alias object containing the ok and error functions to
7
7
  * make it easier to create Result objects.
8
8
  */
9
9
  export type Result<T, E = Error> = {
10
- readonly ok: true;
10
+ readonly error: undefined;
11
11
  readonly value: T;
12
12
  } | {
13
- readonly ok: false;
14
13
  readonly error: E;
15
14
  };
16
15
  export declare const Result: {
17
- success<T>(value: T): Result<T, never>;
16
+ ok<T>(value: T): Result<T, never>;
18
17
  error<E = Error>(error: E): Result<never, E>;
19
18
  };
package/build/index.js CHANGED
@@ -1,15 +1,14 @@
1
- // biome-ignore lint/nursery/useExplicitType: https://github.com/biomejs/biome/issues/5932
2
1
  export const Result = {
3
2
  /**
4
3
  * Creates a successful Result with the given value.
5
4
  * @param value The success value
6
5
  * @returns A Result object representing success
7
6
  */
8
- success: (value) => ({ ok: true, value: value }),
7
+ ok: (value) => ({ error: undefined, value }),
9
8
  /**
10
9
  * Creates an error Result with the given error.
11
10
  * @param error The error value
12
11
  * @returns A Result object representing error
13
12
  */
14
- error: (error) => ({ ok: false, error: error }),
13
+ error: (error) => ({ error }),
15
14
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mkvlrn/result",
3
3
  "description": "Result type for TypeScript",
4
- "version": "1.1.4",
4
+ "version": "2.0.0",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -19,7 +19,7 @@
19
19
  "build": "rm -rf build && tsc"
20
20
  },
21
21
  "devDependencies": {
22
- "@biomejs/biome": "^2.0.0-beta.3",
22
+ "@biomejs/biome": "^2.0.6",
23
23
  "typescript": "^5.8.3"
24
24
  }
25
25
  }