1.0.0 • Published 11 years ago

tree-visitor-async v1.0.0

Weekly downloads
29
License
-
Repository
github
Last release
11 years ago

Tree Visitor Async

Visit nodes in the tree asynchronously and sequentially.

Like Tree Visitor, but actions accept an additional callback function that should be called when it's done processing the node.

API

var VisitorAsync = require('tree-visitor-async');

var nodes = [
	{ type: 'import', value: 'path/to/file1' },
	{ type: 'import', value: 'path/to/file2' },
];
var visitorAsync = new VisitorAsync({
	import: function (visitor, importNode, done) {
		fs.readFile(importNode.value, 'utf8', done);
	}
});
visitorAsync.visit(nodes, function (err) {
	if (err) throw err;
});

visit() also accepts a callback function that will be called when all node in the tree has been processed.