loop-guard
v0.0.0
Published
Guard against loops during tree/graph traversal
Downloads
1
Maintainers
Readme
Loop Guard guards against loops during tree/graph traversal.
Usage
var createGuard = require('loop-guard');
var guard = createGuard();
function visitNode(node) {
guard.visit(node);
for (var i=0; i < node.children.length; i++) {
var child = node.children[i];
if (guard.canVisit(child)) {
visitNode(child);
}
}
guard.leave(node);
}