@kalutskii/foundation 0.1.8 → 0.1.9

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 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. Designed for use in Bun/Node.js and Cloudflare Workers environments.
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.message);
66
+ console.error(safe.error);
66
67
  } else {
67
68
  console.log(safe.data.name);
68
69
  }
package/dist/index.d.ts CHANGED
@@ -25,7 +25,7 @@ type FetchResult<T> = {
25
25
  error: null;
26
26
  data: T;
27
27
  } | {
28
- error: Error;
28
+ error: string;
29
29
  data: null;
30
30
  };
31
31
 
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: new Error(response.error), data: null };
17
+ return { error: response.error, data: null };
18
18
  return { error: null, data: response.data };
19
19
  }
20
20
  async function fetchAndThrow(fetcher) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalutskii/foundation",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Typescript collection of most common utilities, schemas and functions among private projects.",
5
5
  "type": "module",
6
6
  "repository": {