We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function delay(time = 0) { return new Promise((reslove, reject) => { if (time > 2000) { reject(); } else { reslove(time); } }); }; const [error, data] = await to(delay(2100)); console.log(error, data); // error always undefined
This is just a simple example
There are many UI frameworks. Confirm uses project, and reject does not return parameters
The text was updated successfully, but these errors were encountered:
const [error, data] = await to(this.delay(2100),{err: '...'});
Sorry, something went wrong.
const [错误,数据] =等待(this.delay(2100),{err:'...'});
** await-to-js Source code **
export function to<T, U = Error> ( promise: Promise<T>, errorExt?: object ): Promise<[U | null, T | undefined]> { return promise .then<[null, T]>((data: T) => [null, data]) .catch<[U, undefined]>((err: U) => { if (errorExt) { Object.assign(err, errorExt); } return [err, undefined]; }); } export default to;
Error ext is invalid when reject does not return any data.
No branches or pull requests
Demo
This is just a simple example
Why
There are many UI frameworks. Confirm uses project, and reject does not return parameters
The text was updated successfully, but these errors were encountered: