fix: fix keepAlive parameter error (#4194)

* fix: mock server deployment error

* chore: typo
This commit is contained in:
Vben
2024-08-19 23:28:14 +08:00
committed by GitHub
parent 01d60336a6
commit 1db87ff7ce
23 changed files with 115 additions and 101 deletions

View File

@@ -5,6 +5,7 @@ export * from './inference';
export * from './letter';
export * from './merge';
export * from './nprogress';
export * from './to';
export * from './tree';
export * from './unique';
export * from './update-css-variables';

View File

@@ -0,0 +1,21 @@
/**
* @param { Readonly<Promise> } promise
* @param {object=} errorExt - Additional Information you can pass to the err object
* @return { Promise }
*/
export async function to<T, U = Error>(
promise: Readonly<Promise<T>>,
errorExt?: object,
): Promise<[null, T] | [U, undefined]> {
try {
const data = await promise;
const result: [null, T] = [null, data];
return result;
} catch (error) {
if (errorExt) {
const parsedError = Object.assign({}, error, errorExt);
return [parsedError as U, undefined];
}
return [error as U, undefined];
}
}