nodejs将异步变同步的一个小技巧 (function iterator(i){ // 遍历结束 if( i == files.length ){ console.log('...'); return; } fs.stat("./album/" + files[i],function(err,stats){ if(stats.isDirectory()){ // do what you want } itera
(function iterator(i){
// 遍历结束
if( i == files.length ){
console.log('...');
return;
}
fs.stat("./album/" + files[i],function(err,stats){
if(stats.isDirectory()){
// do what you want
}
iterator( i +1 );
});
})(0)
