try-ok 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +5 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -45,9 +45,9 @@ try {
45
45
  With `try-ok`, you handle errors explicitly as return values:
46
46
 
47
47
  ```ts
48
- import { tryResult } from "@sangun-kang/try-ok";
48
+ import { tryOk } from "@sangun-kang/try-ok";
49
49
 
50
- const result = await tryResult(fetch("/api/user").then(r => r.json()));
50
+ const result = await tryOk(fetch("/api/user").then(r => r.json()));
51
51
 
52
52
  // 1. Handle Error First (Type Guard)
53
53
  if (result.isError) {
@@ -63,10 +63,10 @@ console.log(result.data);
63
63
  `try-ok` works well inside React components, especially when calling an existing async function:
64
64
 
65
65
  ```tsx
66
- import { tryResult } from "@sangun-kang/try-ok";
66
+ import { tryOk } from "@sangun-kang/try-ok";
67
67
 
68
68
  export default async function Page() {
69
- const result = await tryResult(getData());
69
+ const result = await tryOk(getData());
70
70
 
71
71
  if (result.isError) {
72
72
  return <div>Oops!</div>;
@@ -95,7 +95,7 @@ You can strictly type your errors if needed:
95
95
  ```ts
96
96
  type ApiError = { status: number; message: string };
97
97
 
98
- const result = await tryResult<User, ApiError>(getUser());
98
+ const result = await tryOk<User, ApiError>(getUser());
99
99
 
100
100
  if (result.isError) {
101
101
  // TypeScript knows this is ApiError
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "try-ok",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Type-safe error handling for async operations using Result pattern",
5
5
  "type": "module",
6
6
  "main": "./dist/try-ok.cjs",