@supernova-studio/model 0.54.22 → 0.54.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/model",
3
- "version": "0.54.22",
3
+ "version": "0.54.24",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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>(timeoutMs: number, promise: () => Promise<T>): Promise<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]);