Walk Coffeescript's AST nodes
Install with npm
npm install coffee-ast-walk --save
Create a ast walker
astwalk = require 'coffee-ast-walk'
root = coffee.nodes source
walk = astwalk(root)
walk.walk (x) ->
console.log x
walk.reduce 0, (x, acc) ->
if @isAstNode then acc + 1 else acc
walk.findFirstByType 'Class'
klass = walk.findFirstByType 'Class'
# fire up another walker
astwalk(klass).findParent ( x ) -> x.__type is 'Assign'
Class | Summary |
---|---|
Walk |
Walk Coffeescript's AST nodes |
WalkCLASS
Walk Coffeescript's AST nodes
:: constructor( __id, __type ) |
public | instance | Walk |
If
| |||
:: walk( [depth][, context] ) |
public | instance | Walk |
The current node is passed ot the visitor. Additionaly,
the following properties are available in the
The visitor callback can invoke Visitor Return Value: If a visitor returns an
| |||
:: findAll( [depth], f ) |
public | instance | Walk |
| |||
:: findFirst( [depth], f ) |
public | instance | Walk |
| |||
:: findByType( t[, depth] ) |
public | instance | Walk |
| |||
:: findFirstByType( t[, depth] ) |
public | instance | Walk |
| |||
:: reduce( ) |
public | instance | Walk |
Updates an internal accumulator to the value returned by
|
Markdown generated by [atomdoc-md](https://github.com/venkatperi/atomdoc-md).