@t1xx1/tsfix 1.0.0 → 1.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.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/trycatch.d.ts +1 -0
- package/dist/trycatch.js +14 -0
- package/package.json +34 -26
- /package/dist/{index.d.ts → _index.d.ts} +0 -0
- /package/dist/{index.js → _index.js} +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# Tsfix
|
|
1
|
+
# Tsfix
|
package/dist/trycatch.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ type Failure<E> = {
|
|
|
7
7
|
error: E;
|
|
8
8
|
};
|
|
9
9
|
export type Result<T, E> = Success<T> | Failure<E>;
|
|
10
|
+
export declare const tryCatchSync: <T, E = Error>(callback: () => T) => Result<T, E>;
|
|
10
11
|
export declare const tryCatch: <T, E = Error>(callback: () => Promise<T>) => Promise<Result<T, E>>;
|
|
11
12
|
export {};
|
package/dist/trycatch.js
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
https://gist.github.com/t3dotgg/a486c4ae66d32bf17c09c73609dacc5b
|
|
3
3
|
https://gist.github.com/T1xx1/0793ede322ebcfcbb6fd0a4c298fe571
|
|
4
4
|
*/
|
|
5
|
+
export const tryCatchSync = (callback) => {
|
|
6
|
+
try {
|
|
7
|
+
return {
|
|
8
|
+
data: callback(),
|
|
9
|
+
error: null,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return {
|
|
14
|
+
data: null,
|
|
15
|
+
error: error,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
5
19
|
export const tryCatch = async (callback) => {
|
|
6
20
|
try {
|
|
7
21
|
return {
|
package/package.json
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@t1xx1/tsfix",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@t1xx1/tsfix",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/t1xx1/tsfix.git"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"package.json",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/_index.js",
|
|
19
|
+
"types": "./dist/_index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "tsc -w",
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"prepublishOnly": "node ./scripts/clean.js && pnpm i && pnpm build"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^6.0.3"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=24"
|
|
32
|
+
},
|
|
33
|
+
"packageManager": "pnpm@11.2.2"
|
|
34
|
+
}
|
|
File without changes
|
|
File without changes
|