3.0.2 • Published 7 years ago

@zdychacek/astw v3.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

astw

This is a fork of astw which uses Babylon parser instead of acorn.

Walks the AST.

example

var astw = require('../');
var walk = astw('4 + beep(5 * 2)');

walk(function (node) {
    console.log(node);
});

methods

var astw = require('@zdychacek/astw')

var walk = astw(src, opts={})

Return a walk() function from the source string or ast object src.

Optionally:

  • opts.parserPlugins - list of plugins for Babylon parser

walk(cb)

Walk the nodes in the ast with cb(node) where node is each element in the ast from babylon but with an additional .parent reference to the parent node.

install

With npm do:

npm install @zdychacek/astw

license

MIT