@rg-dev/stdlib 1.0.2 → 1.0.4
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/lib/common-env.cjs +2 -2
- package/lib/common-env.d.cts +5 -2
- package/lib/common-env.d.ts +5 -2
- package/lib/common-env.js +2 -2
- package/package.json +1 -1
package/lib/common-env.cjs
CHANGED
|
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var common_env_exports = {};
|
|
21
21
|
__export(common_env_exports, {
|
|
22
22
|
Optional: () => Optional,
|
|
23
|
-
|
|
23
|
+
catchInline: () => catchInline,
|
|
24
24
|
doSafe: () => doSafe,
|
|
25
25
|
isNumber: () => isNumber,
|
|
26
26
|
isRunningOnServer: () => isRunningOnServer,
|
|
@@ -113,7 +113,7 @@ function promiseWithTimeout(promise, timeout, errMsg = "The promise timed out.")
|
|
|
113
113
|
() => clearTimeout(timeoutID)
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
|
-
async function
|
|
116
|
+
async function catchInline(promise) {
|
|
117
117
|
try {
|
|
118
118
|
return { result: await promise, err: null };
|
|
119
119
|
} catch (e) {
|
package/lib/common-env.d.cts
CHANGED
|
@@ -5,6 +5,9 @@ type Options = {
|
|
|
5
5
|
};
|
|
6
6
|
declare function promiseRetry<T>(func: (attempt: number) => Promise<T>, options?: Partial<Options>, attempt?: number): Promise<T>;
|
|
7
7
|
|
|
8
|
+
type MyFn<T extends Record<string, (...args: any[]) => any>> = {
|
|
9
|
+
[K in keyof T]: (...args: Parameters<T[K]>) => void;
|
|
10
|
+
};
|
|
8
11
|
declare class Optional<T> {
|
|
9
12
|
private constructor();
|
|
10
13
|
private value;
|
|
@@ -17,7 +20,7 @@ declare class Optional<T> {
|
|
|
17
20
|
declare function sleep(ms: number): Promise<unknown>;
|
|
18
21
|
declare function isNumber(num: any): boolean;
|
|
19
22
|
declare function promiseWithTimeout<T>(promise: Promise<T>, timeout: number, errMsg?: string): Promise<T>;
|
|
20
|
-
declare function
|
|
23
|
+
declare function catchInline<T>(promise: Promise<T>): Promise<{
|
|
21
24
|
err: Error;
|
|
22
25
|
result: T;
|
|
23
26
|
}>;
|
|
@@ -25,4 +28,4 @@ declare function doSafe(safe: () => Promise<void> | void, onError?: (error: Erro
|
|
|
25
28
|
declare function isRunningOnServer(): boolean;
|
|
26
29
|
declare function useServer(fn: () => (Promise<any> | void), onError?: (err: Error) => void): Promise<any>;
|
|
27
30
|
|
|
28
|
-
export { Optional,
|
|
31
|
+
export { type MyFn, Optional, catchInline, doSafe, isNumber, isRunningOnServer, promiseRetry, promiseWithTimeout, sleep, useServer };
|
package/lib/common-env.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ type Options = {
|
|
|
5
5
|
};
|
|
6
6
|
declare function promiseRetry<T>(func: (attempt: number) => Promise<T>, options?: Partial<Options>, attempt?: number): Promise<T>;
|
|
7
7
|
|
|
8
|
+
type MyFn<T extends Record<string, (...args: any[]) => any>> = {
|
|
9
|
+
[K in keyof T]: (...args: Parameters<T[K]>) => void;
|
|
10
|
+
};
|
|
8
11
|
declare class Optional<T> {
|
|
9
12
|
private constructor();
|
|
10
13
|
private value;
|
|
@@ -17,7 +20,7 @@ declare class Optional<T> {
|
|
|
17
20
|
declare function sleep(ms: number): Promise<unknown>;
|
|
18
21
|
declare function isNumber(num: any): boolean;
|
|
19
22
|
declare function promiseWithTimeout<T>(promise: Promise<T>, timeout: number, errMsg?: string): Promise<T>;
|
|
20
|
-
declare function
|
|
23
|
+
declare function catchInline<T>(promise: Promise<T>): Promise<{
|
|
21
24
|
err: Error;
|
|
22
25
|
result: T;
|
|
23
26
|
}>;
|
|
@@ -25,4 +28,4 @@ declare function doSafe(safe: () => Promise<void> | void, onError?: (error: Erro
|
|
|
25
28
|
declare function isRunningOnServer(): boolean;
|
|
26
29
|
declare function useServer(fn: () => (Promise<any> | void), onError?: (err: Error) => void): Promise<any>;
|
|
27
30
|
|
|
28
|
-
export { Optional,
|
|
31
|
+
export { type MyFn, Optional, catchInline, doSafe, isNumber, isRunningOnServer, promiseRetry, promiseWithTimeout, sleep, useServer };
|
package/lib/common-env.js
CHANGED
|
@@ -80,7 +80,7 @@ function promiseWithTimeout(promise, timeout, errMsg = "The promise timed out.")
|
|
|
80
80
|
() => clearTimeout(timeoutID)
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
|
-
async function
|
|
83
|
+
async function catchInline(promise) {
|
|
84
84
|
try {
|
|
85
85
|
return { result: await promise, err: null };
|
|
86
86
|
} catch (e) {
|
|
@@ -134,7 +134,7 @@ function isPromise(value) {
|
|
|
134
134
|
}
|
|
135
135
|
export {
|
|
136
136
|
Optional,
|
|
137
|
-
|
|
137
|
+
catchInline,
|
|
138
138
|
doSafe,
|
|
139
139
|
isNumber,
|
|
140
140
|
isRunningOnServer,
|