example is fixed and summary is extended
example is fixed and summary is extended due to feedbacks
This commit is contained in:
parent
e289aba4ee
commit
0e79e06444
1 changed files with 4 additions and 3 deletions
|
@ -230,7 +230,7 @@ let promise = Promise.any(iterable);
|
||||||
For instance, here the result will be `1`:
|
For instance, here the result will be `1`:
|
||||||
|
|
||||||
```js run
|
```js run
|
||||||
Promise.race([
|
Promise.any([
|
||||||
new Promise((resolve, reject) => setTimeout(() => reject(new Error("Whoops!")), 1000)),
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error("Whoops!")), 1000)),
|
||||||
new Promise((resolve, reject) => setTimeout(() => resolve(1), 2000)),
|
new Promise((resolve, reject) => setTimeout(() => resolve(1), 2000)),
|
||||||
new Promise((resolve, reject) => setTimeout(() => resolve(3), 3000))
|
new Promise((resolve, reject) => setTimeout(() => resolve(3), 3000))
|
||||||
|
@ -302,7 +302,8 @@ There are 5 static methods of `Promise` class:
|
||||||
- `status`: `"fulfilled"` or `"rejected"`
|
- `status`: `"fulfilled"` or `"rejected"`
|
||||||
- `value` (if fulfilled) or `reason` (if rejected).
|
- `value` (if fulfilled) or `reason` (if rejected).
|
||||||
3. `Promise.race(promises)` -- waits for the first promise to settle, and its result/error becomes the outcome.
|
3. `Promise.race(promises)` -- waits for the first promise to settle, and its result/error becomes the outcome.
|
||||||
4. `Promise.resolve(value)` -- makes a resolved promise with the given value.
|
4. `Promise.any(promises)` -- waits for the first promise to fulfill, and its result/error becomes the outcome.
|
||||||
5. `Promise.reject(error)` -- makes a rejected promise with the given error.
|
5. `Promise.resolve(value)` -- makes a resolved promise with the given value.
|
||||||
|
6. `Promise.reject(error)` -- makes a rejected promise with the given error.
|
||||||
|
|
||||||
Of these five, `Promise.all` is probably the most common in practice.
|
Of these five, `Promise.all` is probably the most common in practice.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue