Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rajasegar/ast-node-finder
AST Node Find api automatically generated from code
https://github.com/rajasegar/ast-node-finder
abstract-syntax-tree ast jscodeshift
Last synced: 3 months ago
JSON representation
AST Node Find api automatically generated from code
- Host: GitHub
- URL: https://github.com/rajasegar/ast-node-finder
- Owner: rajasegar
- Archived: true
- Created: 2019-11-21T06:42:39.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-23T09:58:03.000Z (over 2 years ago)
- Last Synced: 2024-07-01T00:21:57.153Z (5 months ago)
- Topics: abstract-syntax-tree, ast, jscodeshift
- Language: TypeScript
- Homepage: https://ast-tooling.vercel.app/
- Size: 1.16 MB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# ast-node-finder
![Build and Deploy](https://github.com/rajasegar/ast-node-finder/workflows/Node%20CI/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/rajasegar/ast-node-finder/badge.svg?branch=refs/heads/master)](https://coveralls.io/github/rajasegar/ast-node-finder?branch=refs/heads/master)
[![Version](https://img.shields.io/npm/v/ast-node-finder.svg)](https://npmjs.org/package/ast-node-finder)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)**WARNING:**
Repository moved here https://github.com/rajasegar/ast-tooling/tree/master/packages/ast-node-finder[jscodeshift](https://github.com/facebook/jscodeshift) find api automatically generated from code
Checkout the api in this [playground](https://rajasegar.github.io/ast-finder/)
Read the [introductory blog post](http://hangaroundtheweb.com/2019/12/ast-finder-finding-ast-nodes-from-code/) for more details.
## Usage
```js
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
```js
root.find(j.CallExpression, {
callee: {
object: { object: { name: 'foo' },
property: { name: 'bar' }
},
property: { name: 'baz' }
}
})
.forEach(path => {
// Manipulate the path (node) here
});
```