ast-node-finder

5.1.0 • Public • Published

ast-node-finder

Build and Deploy Coverage Status Version semantic-release Conventional Commits

jscodeshift find api automatically generated from code

Checkout the api in this playground

Read the introductory blog post for more details.

Usage

import { findQuery } from 'ast-node-finder';
import { parse } from 'recast';

const source = `foo.bar.baz(1,2,3)`;

const ast = parse(source);

// Pass the node from ast and get the find api
console.log(findQuery(ast.program.body[0].expression));

Output

root.find(j.CallExpression, {
  callee: {
    object: {   object: { name: 'foo' },
    property: { name: 'bar' }
  },
  property: { name: 'baz' }
  }
})
.forEach(path => {
  // Manipulate the path (node) here
});

Package Sidebar

Install

npm i ast-node-finder

Weekly Downloads

1

Version

5.1.0

License

MIT

Unpacked Size

85.3 kB

Total Files

9

Last publish

Collaborators

  • rajasegar