Skip to content
This repository was archived by the owner on May 23, 2022. It is now read-only.

rajasegar/ast-node-finder

Repository files navigation

ast-node-finder

Build and Deploy Coverage Status Version semantic-release Conventional Commits

WARNING: Repository moved here https://github.com/rajasegar/ast-tooling/tree/master/packages/ast-node-finder

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
});

About

AST Node Find api automatically generated from code

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 5