Closed antonkulaga closed 11 years ago
Vivagraph supports a short-circuiting for nodes iteration. When callback passed into forEachNode() method returns a truthy value, it considers this a sign that the client does not need to continue the iteration. In case of coffeescript the last statement of the lambda expression is actually a return value. So your code is transpiled to something like
this.graph.forEachNode(function(n) {
var node = {
id: n.id,
data: n.data
};
return nodes.push(node);
});
Obviously, this is not a falsy value, and vivagraph stops the iteration. Return false from the lambda expression and you get them.
Thank you very much for the answer because without it I would spent a lot of time figuring out what to do. In the same time this is a sign that vivagraph needs some refactoring to become more coffee-script friendly.
Glad it worked!
When I iterate over nodes I do not get all of them, here is a gist https://gist.github.com/antonkulaga/5532205 showing this problem.