transformAST
API / publicodes / transformAST
function transformAST(fn, stopOnUpdate): ASTTransformer
This function creates a transormation of the AST from on a simpler
callback function fn
fn
will be called with the nodes of the ASTTree during the exploration
The outcome of the callback function has an influence on the exploration of the AST :
false
, the node is not updated and the exploration does not continue further down this branchundefined
, the node is not updated but the exploration continues and its children will be transformedASTNode
, the node is transformed to the new value and the exploration does not continue further down the branch
updateFn
: It is possible to specifically use the updated version of a child
by using the function passed as second argument. The returned value will be the
transformed version of the node.
Parameters
Parameter | Type | Default value |
---|---|---|
fn | (node , transform ) => undefined | false | ASTNode | undefined |
stopOnUpdate | boolean | true |
Returns
ASTTransformer