Skip to content

Commit

Permalink
updated docs, bump for async updates
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Jun 12, 2012
1 parent 7256213 commit d1a274f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions README.markdown
Expand Up @@ -56,15 +56,19 @@ var falafel = require('falafel')
falafel(src, fn)
----------------

Transform the string source `src` with the function `fn`, returning the
transformed string output.
Transform the string source `src` with the function `fn`, returning a
string-like transformed output object.

For every node in the ast, `fn(node)` fires. The recursive walk is a
pre-traversal, so children get called before their parents.

Performing a pre-traversal makes it easier to write nested transforms since
transforming parents often requires transforming all its children first.

The return value is string-like (it defines `.toString()` and `.inspect()`) so
that you can call `node.update()` asynchronously after the function has
returned and still capture the output.

If `typeof src === 'object'`, then `src.source` will be used for the source and
the rest of the options will be passed directly along to esprima except for
`'range'` which is always turned on because falafel needs it.
Expand Down
1 change: 0 additions & 1 deletion index.js
@@ -1,5 +1,4 @@
var parse = require('esprima').parse;
var json = typeof JSON === 'object' ? JSON : require('jsonify');

module.exports = function (src, fn) {
var opts = {};
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name" : "falafel",
"description" : "transform the ast on a recursive walk",
"version" : "0.0.2",
"version" : "0.1.0",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/node-falafel.git"
Expand Down

0 comments on commit d1a274f

Please sign in to comment.