@kalutskii/foundation 0.1.8 → 0.1.10
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/README.md +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @kalutskii/foundation
|
|
2
2
|
|
|
3
|
-
Collection of utilities, types, and helpers for building typed API contracts and responses in TypeScript projects.
|
|
3
|
+
Collection of utilities, types, and helpers for building typed API contracts and responses in TypeScript projects.
|
|
4
|
+
Designed for use in Bun/Node.js and Cloudflare Workers environments.
|
|
4
5
|
|
|
5
6
|
## What this package provides
|
|
6
7
|
|
|
@@ -62,7 +63,7 @@ declare function getUser(): Promise<APIContractResult<User>>;
|
|
|
62
63
|
|
|
63
64
|
const safe = await fetchSafely(getUser);
|
|
64
65
|
if (safe.error) {
|
|
65
|
-
console.error(safe.error
|
|
66
|
+
console.error(safe.error);
|
|
66
67
|
} else {
|
|
67
68
|
console.log(safe.data.name);
|
|
68
69
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ function failure({ status, error }) {
|
|
|
14
14
|
async function fetchSafely(fetcher) {
|
|
15
15
|
const response = await fetcher();
|
|
16
16
|
if (response.kind === "error")
|
|
17
|
-
return { error:
|
|
17
|
+
return { error: response.error, data: null };
|
|
18
18
|
return { error: null, data: response.data };
|
|
19
19
|
}
|
|
20
20
|
async function fetchAndThrow(fetcher) {
|