reduceAST
API / publicodes / reduceAST
function reduceAST<T>(
fn,
start,
node): T
This function allows to construct a specific value while exploring the AST with a simple reducing function as argument.
fn
will be called with the currently reduced value acc
and the current node of the AST
If the callback function returns:
undefined
, the exploration continues further down and all the children are reduced successively to a single valueT
, the reduced value is returned
reduceFn
: It is possible to specifically use the reduced value of a child
by using the function passed as second argument. The returned value will be the reduced version
of the node
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
fn | (acc , n , reduceFn ) => undefined | T |
start | T |
node | ASTNode |
Returns
T