I'm trying to traverse a tree of nested of items using async.js. The traversal terminates after going through just one branch.
var count=0;
exports.buildFamily = function(item_id, mback){
var extendedFamily={};
exports.getItembyId(item_id, function(err, item){
extendedFamily=item;
if(item.descendants){
extendedFamily.kids=[];
count=+item.descendants.length;
console.log('outercount ' + count);
async.eachSeries(item.descendants, function(item){
count--
console.log('item: ' + item)
exports.buildFamily(item, function(err, family){
console.log('deepcount: ' + count);
extendedFamily.kids.push(family);
if(count===0){ return mback(null, extendedFamily);}
else {extendedFamily.kids.push(family);}
})
})
}
else{
if(count===0){ return mback(null, extendedFamily);}
else{
extendedFamily.kids.push(family);
return;
}
}
});
};
=+
is not the javascript addition assignment operator . . . – Dempster