Skip to content

Commit

Permalink
add simple example for basic concept section
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Oct 30, 2014
1 parent 51edd79 commit 5536f31
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lesson17/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fs.readFile('sample01.txt','utf8',function(err,data){

这段代码就是臭名昭著的邪恶金字塔(Pyramid of Doom)。可以使用async来改善这段代码,但是在本课中我们要用promise/defer来改善它。

## 基本概念
## promise基本概念
先学习promise的基本概念。

*promise只有三种状态,未完成,完成(fulfiled)和失败(rejected)。
Expand All @@ -91,6 +91,8 @@ promiseSomething().then(function(fulfiled){
});
```

## promise的传递

这次我们要介绍的是 async 的 `mapLimit(arr, limit, iterator, callback)` 接口。另外,还有个常用的控制并发连接数的接口是 `queue(worker, concurrency)`,大家可以去 https://github.com/caolan/async#queueworker-concurrency 看看说明。

这回我就不带大家爬网站了,我们来专注知识点:并发连接数控制。
Expand Down

0 comments on commit 5536f31

Please sign in to comment.