{"_id":"@ast-grep/ast-grep-wasm","name":"@ast-grep/ast-grep-wasm","dist-tags":{"latest":"0.40.5"},"versions":{"0.40.5":{"name":"@ast-grep/ast-grep-wasm","type":"module","collaborators":["Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>"],"description":"Search and Rewrite code at large scale using precise AST pattern","version":"0.40.5","license":"MIT","repository":{"type":"git","url":"git+https://github.com/ast-grep/ast-grep.git"},"main":"ast_grep_wasm.js","types":"ast_grep_wasm.d.ts","sideEffects":["./snippets/*"],"keywords":["ast","pattern","codemod","search","rewrite"],"_id":"@ast-grep/ast-grep-wasm@0.40.5","gitHead":"fd49dcdbfd72b8af773d5279fdbf37a2425632ad","bugs":{"url":"https://github.com/ast-grep/ast-grep/issues"},"homepage":"https://github.com/ast-grep/ast-grep#readme","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-MK6piQP7iI+3Mjk99Siaq/6kxpWPMvRP5GG9PanU4+McZrAcR3/dR+na7xcpLmskuEwWrEzLd+T8zPAlMvYUfg==","shasum":"820f4a53582b13138be7060a370175cfc902caad","tarball":"https://registry.npmjs.org/@ast-grep/ast-grep-wasm/-/ast-grep-wasm-0.40.5.tgz","fileCount":5,"unpackedSize":1902042,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH4AkiDKYOtolbnSAVPJ5JkMTiz96rmsc62KDCVs4iEWAiEAsPFIIYlxvd19ZHsfr0hA/zckKfs+iAn+Wz0wz0yo4vY="}]},"_npmUser":{"name":"herringtondarkholme","email":"nonamesheep@outlook.com"},"directories":{},"maintainers":[{"name":"herringtondarkholme","email":"nonamesheep@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ast-grep-wasm_0.40.5_1771715487635_0.6934043508662802"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-21T23:11:27.526Z","0.40.5":"2026-02-21T23:11:27.855Z","modified":"2026-02-21T23:11:28.104Z"},"maintainers":[{"name":"herringtondarkholme","email":"nonamesheep@outlook.com"}],"description":"Search and Rewrite code at large scale using precise AST pattern","homepage":"https://github.com/ast-grep/ast-grep#readme","keywords":["ast","pattern","codemod","search","rewrite"],"repository":{"type":"git","url":"git+https://github.com/ast-grep/ast-grep.git"},"bugs":{"url":"https://github.com/ast-grep/ast-grep/issues"},"license":"MIT","readme":"# @ast-grep/wasm\n\nWebAssembly build of [ast-grep](https://ast-grep.github.io/) for use in browsers and Node.js.\n\nThis package provides the same API as [`@ast-grep/napi`](https://www.npmjs.com/package/@ast-grep/napi) but runs in any JavaScript environment that supports WebAssembly, including browsers, Deno, and edge runtimes.\n\n## Installation\n\n```bash\nyarn add @ast-grep/wasm web-tree-sitter\n```\n\n`web-tree-sitter` is a required peer dependency.\n\n## Usage\n\n```js\nimport { initializeTreeSitter, setupParser, parse, kind } from '@ast-grep/wasm'\n\n// 1. Initialize the tree-sitter WASM runtime (once)\nawait initializeTreeSitter()\n\n// 2. Load a language parser WASM binary\nawait setupParser('javascript', '/path/to/tree-sitter-javascript.wasm')\n\n// 3. Parse and search code\nconst sg = parse('javascript', 'console.log(\"hello world\")')\nconst node = sg.root().find('console.log($ARG)')\nconsole.log(node.getMatch('ARG').text()) // \"hello world\"\n```\n\n### Pattern Matching\n\n```js\n// By pattern string\nsg.root().find('console.log($$$ARGS)')\n\n// By kind number\nconst k = kind('javascript', 'call_expression')\nsg.root().find(k)\n\n// By rule config (same as YAML rules)\nsg.root().find({\n  rule: { pattern: 'console.log($A)' },\n  constraints: { A: { kind: 'string' } },\n})\n```\n\n### Code Rewriting\n\n```js\nconst match = sg.root().find('console.log($A)')\nconst edit = match.replace('console.error($A)')\nconst newCode = sg.root().commitEdits([edit])\n```\n\n## Supported Languages\n\nbash, c, cpp, csharp, css, elixir, go, haskell, html, java, javascript, json, kotlin, lua, nix, php, python, ruby, rust, scala, swift, tsx, typescript, yaml\n\n## API Reference\n\nSee the full [ast-grep API documentation](https://ast-grep.github.io/reference/api.html).\n\n## Building from Source\n\nRequires [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/).\n\n```bash\n# For browser (ES module)\nyarn build\n\n# For Node.js (CommonJS)\nyarn build:nodejs\n\n# For bundlers\nyarn build:bundler\n```\n\n## Testing\n\n```bash\nyarn install\n```\n\n### Rust WASM tests\n\n```bash\nyarn test\n```\n\n> **Note:** `wasm-pack test --node` runs the test harness from a temporary directory.\n> The `test` script sets `NODE_PATH=$PWD/node_modules` so that `web-tree-sitter` and\n> parser WASM files can be resolved. If you run `wasm-pack test --node` directly,\n> set `NODE_PATH` yourself:\n>\n> ```bash\n> NODE_PATH=$PWD/node_modules wasm-pack test --node\n> ```\n\n### JavaScript tests\n\n```bash\nyarn test:js\n```\n\nThis builds the WASM package for Node.js and runs AVA tests against it.\n","readmeFilename":"README.md","_rev":"1-346b5295377f03f6bc7ed76de247b430"}