1.0.0 • Published 11 years ago

tree-transformer-async v1.0.0

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

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]
});