@supernova-studio/model 0.54.23 → 0.54.25
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/utils/common.ts +6 -2
package/package.json
CHANGED
package/src/utils/common.ts
CHANGED
|
@@ -104,10 +104,14 @@ export function buildConstantEnum<Inferred extends ArrayElementType<Passed>[], P
|
|
|
104
104
|
return constMap as { [key in Inferred[number]]: key };
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
export async function promiseWithTimeout<T>(
|
|
107
|
+
export async function promiseWithTimeout<T>(
|
|
108
|
+
timeoutMs: number,
|
|
109
|
+
promise: () => Promise<T>,
|
|
110
|
+
onTimeout?: () => Error
|
|
111
|
+
): Promise<T> {
|
|
108
112
|
let timeoutHandle: NodeJS.Timeout | undefined;
|
|
109
113
|
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
110
|
-
timeoutHandle = setTimeout(() => reject(SupernovaException.timeout()), timeoutMs);
|
|
114
|
+
timeoutHandle = setTimeout(() => reject(onTimeout?.() ?? SupernovaException.timeout()), timeoutMs);
|
|
111
115
|
});
|
|
112
116
|
|
|
113
117
|
const result = await Promise.race([promise(), timeoutPromise]);
|