@@ -47,29 +47,29 @@ produce a meaningful state. (An example of a use of state is to track
4747scope at each point in the tree.)
4848
4949``` js
50- const acorn = require ( " acorn" )
51- const walk = require ( " acorn-walk" )
50+ import * as acorn from " acorn" ;
51+ import * as walk from " acorn-walk" ;
5252
5353walk .simple (acorn .parse (" let x = 10" ), {
5454 Literal (node ) {
55- console .log (` Found a literal: ${ node .value } ` )
55+ console .log (` Found a literal: ${ node .value } ` );
5656 }
57- })
57+ });
5858```
5959
6060** ancestor** ` (node, visitors, base, state) ` does a 'simple' walk over
6161a tree, building up an array of ancestor nodes (including the current node)
6262and passing the array to the callbacks as a third parameter.
6363
6464``` js
65- const acorn = require ( " acorn" )
66- const walk = require ( " acorn-walk" )
65+ import * as acorn from " acorn" ;
66+ import * as walk from " acorn-walk" ;
6767
6868walk .ancestor (acorn .parse (" foo('hi')" ), {
6969 Literal (_node , _state , ancestors ) {
70- console .log (" This literal's ancestors are:" , ancestors .map (n => n .type ))
70+ console .log (" This literal's ancestors are:" , ancestors .map (n => n .type ));
7171 }
72- })
72+ });
7373```
7474
7575** recursive** ` (node, state, functions, base) ` does a 'recursive'
@@ -97,12 +97,12 @@ current node) and passing the array to the callbacks as a third
9797parameter.
9898
9999``` js
100- const acorn = require ( " acorn" )
101- const walk = require ( " acorn-walk" )
100+ import * as acorn from " acorn" ;
101+ import * as walk from " acorn-walk" ;
102102
103103walk .full (acorn .parse (" 1 + 1" ), node => {
104- console .log (` There's a ${ node .type } node at ${ node .ch } ` )
105- })
104+ console .log (` There's a ${ node .type } node at ${ node .ch } ` );
105+ });
106106```
107107
108108** findNodeAt** ` (node, start, end, test, base, state) ` tries to locate
0 commit comments