fs.readFile()'s callback takes 2 args (err and data) as follow:
fs.readFile('/etc/passwd', function (err, data) {
if (err) throw err;
console.log(data);
});
So when you pass in async.series()'s callback 'next', fs.readFile() calls it as next(err, data) where data will finally be in async's result array. If however, you want to do something to data before you pass to the async's result array, you can do this:
function readTheFile(next) {
var result1 = 'something';
fs.readFile('file.txt', 'utf8', function(err, data) {
if (err) {
// handle error
}
// do some thing with data argument, such as parsing
// or triming (data = data.trim() for example), or
// assign it to result1 (result1 = data), then call next()
next(err, result1); // this will pass your result1 to async's final array
});
}