tree-transformer-async
v1.0.0
Published
Transform nodes in the tree asynchronously and sequentially
Downloads
46
Readme
Tree Transformer Async
Transform nodes in the tree asynchronously and sequentially.
Asynchronous version of Tree Transformer. Like Tree Visitor Async.
API
var fs = require('fs');
var TransformerAsync = require('tree-transformer-async');
var nodes = [
{ type: 'import', value: 'path/to/file1' },
{ type: 'import', value: 'path/to/file2' },
];
var transformerAsync = new TransformerAsync({
import: function (visitor, importNode, done) {
fs.readFile(importNode.value, 'utf8', done);
}
});
transformerAsync.visit(nodes, function (err, result) {
if (err) throw err;
console.log(result); // [content of file1, content of file2]
});