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
Promise.race方法同样是将多个 Promise 实例,包装成一个新的 Promise 实例
const p = Promise.race([p1, p2, p3]);
上面代码中,只要p1、p2、p3之中有一个实例率先改变状态,p的状态就跟着改变
Promise.race = promises => new Promise((resolve, reject) => { promises.forEach(promise => { promise.then(resolve, reject) }) })
ECMAScript 6 入门 - 阮一峰
The text was updated successfully, but these errors were encountered:
sihai00
No branches or pull requests
手写Promise.race
Promise.race方法同样是将多个 Promise 实例,包装成一个新的 Promise 实例
上面代码中,只要p1、p2、p3之中有一个实例率先改变状态,p的状态就跟着改变
实现
参考
ECMAScript 6 入门 - 阮一峰
The text was updated successfully, but these errors were encountered: