Skip to content

Instantly share code, notes, and snippets.

@wegrata
Created March 1, 2013 21:16
Show Gist options
  • Save wegrata/5067838 to your computer and use it in GitHub Desktop.
Save wegrata/5067838 to your computer and use it in GitHub Desktop.
function process_tree(queue){
if(queue.length >= 0){
var node = queue.pop();
client.get(node.id, function(err, result){
node.count = result;
for(var child in node.children){
queue.push(node.children[child]);
}
process_tree(queue);
});
}else{
response.header("Access-Control-Allow-Origin", "*");
response.header("Access-Control-Allow-Methods", "GET");
response.header("Access-Control-Allow-Headers", "*");
response.header("Content-Type", "application/json");
response.end(JSON.stringify(viewOptions.locals.categories));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment