Browse files

document new signature

  • Loading branch information...
1 parent 1c8ef7c commit 86154f72806200b71b71f51f375551a65624569e @substack committed Aug 25, 2012
Showing with 16 additions and 26 deletions.
  1. +15 −25 README.markdown
  2. +1 −1 package.json
@@ -1,5 +1,4 @@
+# falafel
Transform the [ast]( on a
recursive walk.
@@ -11,11 +10,9 @@ except that it uses [esprima]( instead of
for friendlier-looking ast nodes.
+# example
+## array.js
Put a function wrapper around all array literals.
@@ -46,15 +43,13 @@ output:
+# methods
``` js
var falafel = require('falafel')
-falafel(src, fn)
+## falafel(src, opts={}, fn)
Transform the string source `src` with the function `fn`, returning a
string-like transformed output object.
@@ -69,52 +64,47 @@ 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.
+Instead of passing a `src` you can also use `opts.source`.
+All of the `opts` will be passed directly to esprima except for `'range'` which
+is always turned on because falafel needs it.
Some of the options you might want from esprima includes:
`'loc'`, `'raw'`, `'comments'`, `'tokens'`, and `'tolerant'`.
+# nodes
Aside from the regular [esprima]( data, you can also call
some inserted methods on nodes.
Aside from updating the current node, you can also reach into sub-nodes to call
update functions on children from parent nodes.
+## node.source()
Return the source for the given node, including any modifications made to
children nodes.
+## node.update(s)
Transform the source for the present node to the string `s`.
Note that in `'ForStatement'` node types, there is an existing subnode called
`update`. For those nodes all the properties are copied over onto the
`node.update()` function.
+## node.parent
Reference to the parent element or `null` at the root element.
+# install
With [npm]( do:
npm install falafel
+# license
@@ -1,7 +1,7 @@
"name" : "falafel",
"description" : "transform the ast on a recursive walk",
- "version" : "0.1.2",
+ "version" : "0.1.3",
"repository" : {
"type" : "git",
"url" : "git://"

0 comments on commit 86154f7

Please sign in to comment.