@rozoai/intent-common 0.0.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.
package/src/try.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { debugJson } from "./debug";
2
+
3
+ export async function awaitOrNull<T>(fn: () => Promise<T>): Promise<T | null> {
4
+ try {
5
+ return await fn();
6
+ } catch (e) {
7
+ return null;
8
+ }
9
+ }
10
+
11
+ export function tryOrNull<T>(fn: () => T): T | null {
12
+ try {
13
+ return fn();
14
+ } catch (e) {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ export async function awaitDebug<T>(fn: () => Promise<T>): Promise<string> {
20
+ try {
21
+ return debugJson(await fn());
22
+ } catch (e: any) {
23
+ return `<error: ${e}>`;
24
+ }
25
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "@tsconfig/node20/tsconfig.json",
3
+ "compilerOptions": {
4
+ "strict": true,
5
+ "resolveJsonModule": true,
6
+ "sourceMap": true,
7
+ "outDir": "dist",
8
+ "declaration": true,
9
+ "esModuleInterop": true
10
+ },
11
+ "include": ["src/**/*.ts"]
12
+ }