Skip to content

Commit 4b5192b

Browse files
committed
Use Promises, not callbacks
1 parent 93398be commit 4b5192b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

README-zh-CN.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,11 +1899,14 @@ describe('MakeMomentJSGreatAgain', () => {
18991899
**[⬆ 返回顶部](#代码整洁的-javascript)**
19001900

19011901
## **并发**
1902-
### Use Promises, not callbacks
1902+
### 使用 Promises, 不要使用回调
19031903
Callbacks aren't clean, and they cause excessive amounts of nesting. With ES2015/ES6,
19041904
Promises are a built-in global type. Use them!
19051905

1906-
**Bad:**
1906+
回调不够简洁, 因为他们会产生过多的嵌套。 在 ES2015/ES6 中, Promises 已经是内置的全局类型
1907+
了,使用它们吧!
1908+
1909+
**不好的:**
19071910
```javascript
19081911
require('request').get('https://en.wikipedia.org/wiki/Robert_Cecil_Martin', (requestErr, response) => {
19091912
if (requestErr) {
@@ -1921,7 +1924,7 @@ require('request').get('https://en.wikipedia.org/wiki/Robert_Cecil_Martin', (req
19211924

19221925
```
19231926

1924-
**Good**:
1927+
**好的:**
19251928
```javascript
19261929
require('request-promise').get('https://en.wikipedia.org/wiki/Robert_Cecil_Martin')
19271930
.then((response) => {

0 commit comments

Comments
 (0)