ast-children
get the children of an AST node
Installation
npm install ast-children
then in your app:
const children =
API
children(node)
Takes a standard AST node and returns an Array
of its child nodes
var ast = type: 'Program' body: type: 'VariableDeclaration' declarations: type: 'VariableDeclarator' id: type: 'Identifier' name: 'a' init: type: 'Literal' value: 1 type: 'VariableDeclarator' id: type: 'Identifier' name: 'b' // => ast.body // => ast.body[0].declarationsvar decs = astbody0declarations // => [decs[0].id, decs[0].init] // => [decs[1].id]