Skip to content

Commit

Permalink
move array declaration down
Browse files Browse the repository at this point in the history
  • Loading branch information
freewind committed May 18, 2012
1 parent 8c1b34e commit 7b7aa60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ var async = require('async');
var t = require('./t');
var log = t.log;

var arr = [{name:'Jack', delay:200}, {name:'Mike', delay: 100}, {name:'Freewind', delay:300}, {name:'Test', delay: 50}];

/**
* 对集合中的每一个元素,执行某个异步操作,得到结果。所有的结果将汇总到最终的callback里。与forEach的区别是,forEach只关心操作不管最后的值,而map关心的最后产生的值。
*
Expand All @@ -14,6 +12,8 @@ var arr = [{name:'Jack', delay:200}, {name:'Mike', delay: 100}, {name:'Freewind'
*/
// map(arr, iterator(item, callback), callback(err, results))

var arr = [{name:'Jack', delay:200}, {name:'Mike', delay: 100}, {name:'Freewind', delay:300}, {name:'Test', delay: 50}];

/**
* 所有操作均正确执行,未出错。所有结果按元素顺序汇总给最终的callback。
*/
Expand Down

0 comments on commit 7b7aa60

Please sign in to comment.