Skip to content

Node.js based forum software built for the modern web

change to async.each for addUserInfoToPosts

Baris Usakli03d3f598045b
diff --git a/src/topics.js b/src/topics.js
index 715122cc3e..1d8eef2f92 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -51,16 +51,15 @@ marked.setOptions({
}
function addUserInfoToPosts(next) {
- var done = 0;
-
- for(var i=0, ii=postData.length; i<ii; ++i) {
-
- posts.addUserInfoToPost(postData[i], function() {
- ++done;
- if(done === postData.length)
- next(null, null);
+ function iterator(post, callback) {
+ posts.addUserInfoToPost(post, function() {
+ callback(null);
});
}
+
+ async.each(postData, iterator, function(err) {
+ next(err, null);
+ });
}
function getPrivileges(next) {