You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Step(
function readDir() {
fs.readdir(__dirname, *this*); <--------
},
function readFiles(err, results) {
if (err) throw err;
// Create a new group
* var group = this.group() *; <--------
results.forEach(function (filename) {
if (/\.js$/.test(filename)) {
fs.readFile(__dirname + "/" + filename, 'utf8', *group()*); <--------
}
});
},
function showAll(err , files) {
if (err) throw err;
console.dir(files);
}
);
can just use this more clear code instead, replace all (this, this.group, this.async) away, step jsut play a trick, it sell you something you just have own already.
var fs = require('fs');
fs.readdir(__dirname, readFiles);
function readFiles(err, results){
if (err) throw err;
// Create a new group
async.map(results, function(filename, cb){ <-------- use async.map to finally get all async result
if (/\.js$/.test(filename)) {
fs.readFile(__dirname + "/" + filename, 'utf8', cb);
}
}, showAll);
}
function showAll(err, files){
if (err) throw err;
console.dir(files);
}
The text was updated successfully, but these errors were encountered:
the code example in step's readme
can just use this more clear code instead, replace all (this, this.group, this.async) away, step jsut play a trick, it sell you something you just have own already.
The text was updated successfully, but these errors were encountered: