UNPKG

ast-node-finder

Version:

JSCodeshift find api automatically generated from code

57 lines 3.07 kB
{ "name": "ast-node-finder", "version": "5.1.0", "description": "JSCodeshift find api automatically generated from code", "main": "dist/ast-node-finder.cjs.js", "module": "dist/ast-node-finder.esm.js", "browser": "dist/ast-node-finder.umd.js", "files": [ "dist" ], "keywords": [ "ast", "jscodeshift", "ast-explorer" ], "author": "Rajasegar Chandran", "repository": "https://github.com/rajasegar/ast-tooling", "license": "MIT", "devDependencies": { "@babel/core": "7.17.8", "@babel/preset-env": "7.16.11", "@babel/preset-typescript": "7.16.7", "@rollup/plugin-commonjs": "21.0.3", "@rollup/plugin-node-resolve": "13.1.3", "@rollup/plugin-typescript": "8.3.1", "@types/common-tags": "^1.8.1", "babel-jest": "27.5.1", "coveralls": "3.1.1", "eslint": "8.12.0", "eslint-config-standard": "16.0.3", "eslint-plugin-promise": "6.0.0", "eslint-plugin-standard": "5.0.0", "jest": "27.5.1", "rollup": "2.70.1", "ts-node": "10.7.0", "tslib": "2.3.1", "typescript": "4.6.3" }, "dependencies": { "common-tags": "^1.8.2", "ember-template-recast": "^6.1.3", "recast": "^0.20.5" }, "engines": { "node": ">=12.0.0" }, "scripts": { "start": "rollup -c -w", "dev": "rollup -c -w", "build": "rollup -c", "test": "jest", "coverage": "coveralls", "lint": "eslint .", "debug": "mocha --forbid-only --inspect-brk \"test/**/*.test.js\"" }, "readme": "# ast-node-finder\n![Build and Deploy](https://github.com/rajasegar/ast-node-finder/workflows/Node%20CI/badge.svg)\n[![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)\n[![Version](https://img.shields.io/npm/v/ast-node-finder.svg)](https://npmjs.org/package/ast-node-finder)\n[![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)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n\n\n[jscodeshift](https://github.com/facebook/jscodeshift) find api automatically generated from code\n\nCheckout the api in this [playground](https://rajasegar.github.io/ast-finder/)\n\nRead the [introductory blog post](http://hangaroundtheweb.com/2019/12/ast-finder-finding-ast-nodes-from-code/) for more details.\n\n## Usage\n```js\nimport { findQuery } from 'ast-node-finder';\nimport { parse } from 'recast';\n\nconst source = `foo.bar.baz(1,2,3)`;\n\nconst ast = parse(source);\n\n// Pass the node from ast and get the find api\nconsole.log(findQuery(ast.program.body[0].expression));\n```\n\n### Output\n\n```js\nroot.find(j.CallExpression, {\n callee: {\n object: { object: { name: 'foo' },\n property: { name: 'bar' }\n },\n property: { name: 'baz' }\n }\n})\n.forEach(path => {\n // Manipulate the path (node) here\n});\n```\n\n" }