Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name the callback function(s) #33

Merged
merged 1 commit into from Oct 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/each/solution/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ async.each(process.argv.slice(2), function(item, done){
done(err);
});
},
function(err){
function done(err){
if(err) console.log(err);
});
2 changes: 1 addition & 1 deletion exercises/map/solution/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async.map(process.argv.slice(2), function(url, done){
});
});
},
function(err, results){
function done(err, results){
if (err) return console.log(err);
// results is an array of the response bodies in the same order
console.log(results);
Expand Down
6 changes: 3 additions & 3 deletions exercises/reduce/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var http = require('http')
, async = require('async');

async.reduce(['one', 'two', 'three'], 0, function(memo, item, callback){
async.reduce(['one', 'two', 'three'], 0, function(memo, item, done){
var body = '';

http.get(process.argv[2] + "?number=" + item, function(res){
Expand All @@ -12,9 +12,9 @@ async.reduce(['one', 'two', 'three'], 0, function(memo, item, callback){
res.on('end', function(){
callback(null, memo + Number(body));
});
}).on('error', callback);
}).on('error', done);

}, function(err, result){
}, function done(err, result){
if (err) return console.log(err);
console.log(result);
});
2 changes: 1 addition & 1 deletion exercises/series_object/solution/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async.series({
fetchURL(process.argv[3], done);
}
},
function(err, result){
function done(err, result){
if (err) return console.error(err);
console.log(result);
});
Expand Down
8 changes: 4 additions & 4 deletions exercises/times/solution/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async.series({
_addUser(++n, function(err){
next(err);
});
}, function(err){
}, function next(err){
if (err) return done(err);
done(null, 'saved');
});
Expand All @@ -30,13 +30,13 @@ async.series({
}).on('error', done);
}

}, function(err, result){
}, function done(err, result){
if (err) return console.log(err);
console.log(result.get);
});


function _addUser(user_id, cb){
function _addUser(user_id, next){
var postdata = JSON.stringify({'user_id': user_id}),
opts = {
hostname: hostname,
Expand All @@ -52,7 +52,7 @@ function _addUser(user_id, cb){
res.on('data', function(chunk){})

res.on('end', function(){
cb();
next();
});
});

Expand Down
2 changes: 1 addition & 1 deletion exercises/waterfall/solution/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async.waterfall([
done(e);
});
}
], function(err, result){
], function done(err, result){
if (err) return console.error(err);
console.log(result);
});