Skip to content

Commit f6199af

Browse files
committed
docs(async): fix async ruanyf#787
1 parent 52bca44 commit f6199af

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/async.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ asyncReadFile();
5959

6060
(3)更广的适用性。
6161

62-
`co`模块约定,`yield`命令后面只能是 Thunk 函数或 Promise 对象,而`async`函数的`await`命令后面,可以是 Promise 对象和原始类型的值(数值、字符串和布尔值,但这时等同于同步操作)。
62+
`co`模块约定,`yield`命令后面只能是 Thunk 函数或 Promise 对象,而`async`函数的`await`命令后面,可以是 Promise 对象和原始类型的值(数值、字符串和布尔值,但这时会自动转成立即 resolved 的 Promise 对象)。
6363

6464
(4)返回值是 Promise。
6565

docs/promise.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ getJSON("/post/1.json").then(
251251

252252
## Promise.prototype.catch()
253253

254-
`Promise.prototype.catch`方法是`.then(null, rejection)`的别名,用于指定发生错误时的回调函数。
254+
`Promise.prototype.catch`方法是`.then(null, rejection)``.then(undefined, rejection)`的别名,用于指定发生错误时的回调函数。
255255

256256
```javascript
257257
getJSON('/posts.json').then(function(posts) {
@@ -993,7 +993,7 @@ try {
993993
上面这样的写法就很笨拙了,这时就可以统一用`promise.catch()`捕获所有同步和异步的错误。
994994

995995
```javascript
996-
Promise.try(database.users.get({id: userId}))
996+
Promise.try(() => database.users.get({id: userId}))
997997
.then(...)
998998
.catch(...)
999999
```

0 commit comments

Comments
 (0)