{"_id":"@rtinternal/tree-sitter","name":"@rtinternal/tree-sitter","dist-tags":{"latest":"0.22.4-rtinternal"},"versions":{"0.22.4-rtinternal":{"name":"@rtinternal/tree-sitter","version":"0.22.4-rtinternal","description":"[Fork of tree-sitter/node-tree-sitter] Node.js bindings to the Tree-sitter parsing library","repository":{"type":"git","url":"git+ssh://git@github.com/tree-sitter/node-tree-sitter.git"},"publishConfig":{"access":"public"},"license":"MIT","author":{"name":"Max Brunsfeld","email":"maxbrunsfeld@gmail.com"},"maintainers":[{"name":"rt-mattw","email":"mattw@retool.com"},{"name":"rt-bot","email":"retool-bot@retool.com"}],"contributors":[{"name":"Segev Finer","email":"segev208@gmail.com"},{"name":"Boris Verkhovskiy","email":"boris.verk@gmail.com"}],"main":"index.js","types":"tree-sitter.d.ts","keywords":["incremental","parsing","tree-sitter"],"dependencies":{"@mapbox/node-pre-gyp":"^1.0.8","node-addon-api":"^8.3.0","node-gyp-build":"^4.8.4"},"binary":{"module_name":"tree_sitter_runtime_binding","package_name":"{module_name}-v{version}-{node_abi}-napi{napi_build_version}-{platform}-{arch}.tar.gz","module_path":"./build-tmp-napi-v{napi_build_version}/Release/","host":"https://rtinternal.s3.amazonaws.com/","napi_versions":[9]},"devDependencies":{"aws-sdk":"^2.1095.0","@types/node":"^22.10.2","@types/tmp":"^0.2.6","glob":"^11.0.0","node-gyp":"^11.0.0","prebuildify":"^6.0.1","tmp":"^0.2.3","tree-sitter-c":"^0.23.4","tree-sitter-embedded-template":"^0.23.2","tree-sitter-html":"^0.23.2","tree-sitter-java":"^0.23.5","tree-sitter-javascript":"^0.23.1","tree-sitter-json":"^0.24.8","tree-sitter-python":"^0.23.6","tree-sitter-ruby":"^0.23.1","tree-sitter-rust":"^0.23.2","typedoc":"^0.27.6","typedoc-plugin-rename-defaults":"^0.7.2","typescript":"^5.7.2"},"scripts":{"docs":"typedoc --out docs/api tree-sitter.d.ts --readme README.md","install":"node-pre-gyp install --fallback-to-build","build":"prebuildify --napi --strip","rebuild":"node-gyp rebuild","test":"node -e \"require('child_process').spawnSync('node', ['--test', ...require('glob').sync('test/**/*.js')], {stdio:'inherit'})\""},"_id":"@rtinternal/tree-sitter@0.22.4-rtinternal","gitHead":"2c3f402ff3df47574e98baca7ebb3bb78201fb59","bugs":{"url":"https://github.com/tree-sitter/node-tree-sitter/issues"},"homepage":"https://github.com/tree-sitter/node-tree-sitter#readme","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Ay7+1WKOzuUgw411mpOZLBMFyag4jTF5ISaXDHq8f04ue+m/vpsWLlr9QnuwQPtgltzNW1Zg99EfpvKWKbA7JQ==","shasum":"40cf3769812033f1b3975fe9d428eb0196f3d418","tarball":"https://registry.npmjs.org/@rtinternal/tree-sitter/-/tree-sitter-0.22.4-rtinternal.tgz","fileCount":74,"unpackedSize":906259,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCID7da+V46uGiGwOkjSSgp0iUV3mjSpIiRk2LhRxVUsvFAiEAyYz9lSupkoX1y/HBv2RmKxof9h1VXBYo6i4IduIRBjc="}]},"_npmUser":{"name":"rt-mattw","email":"mattw@retool.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tree-sitter_0.22.4-rtinternal_1752701603965_0.8668117697643216"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-16T21:33:23.843Z","0.22.4-rtinternal":"2025-07-16T21:33:24.221Z","modified":"2025-07-16T21:33:24.803Z"},"maintainers":[{"name":"rt-mattw","email":"mattw@retool.com"},{"name":"rt-bot","email":"retool-bot@retool.com"}],"description":"[Fork of tree-sitter/node-tree-sitter] Node.js bindings to the Tree-sitter parsing library","homepage":"https://github.com/tree-sitter/node-tree-sitter#readme","keywords":["incremental","parsing","tree-sitter"],"repository":{"type":"git","url":"git+ssh://git@github.com/tree-sitter/node-tree-sitter.git"},"contributors":[{"name":"Segev Finer","email":"segev208@gmail.com"},{"name":"Boris Verkhovskiy","email":"boris.verk@gmail.com"}],"author":{"name":"Max Brunsfeld","email":"maxbrunsfeld@gmail.com"},"bugs":{"url":"https://github.com/tree-sitter/node-tree-sitter/issues"},"license":"MIT","readme":"# Node Tree-sitter\n\n[![CI][ci]](https://github.com/tree-sitter/node-tree-sitter/actions/workflows/ci.yml)\n[![npm][npm]](https://npmjs.com/package/tree-sitter)\n[![docs][docs]](https://tree-sitter.github.io/node-tree-sitter)\n\nThis module provides Node.js bindings to the [tree-sitter] parsing library.\n\n## Installation\n\n```sh\nnpm install tree-sitter\n```\n\n## Basic Usage\n\n### Prerequisites\n\nFirst, you'll need a Tree-sitter grammar for the language you want to parse. There are many [existing grammars][grammars],\nsuch as [tree-sitter-javascript][javascript]. These grammars can typically be installed with a package manager like NPM,\nso long as the author has published them.\n\n```sh\nnpm install tree-sitter-javascript\n```\n\nYou can also develop a new grammar by using the [Tree-sitter CLI][cli] and following the [docs][ts docs].\n\n### Parsing Source Code\n\nOnce you've got your grammar, create a parser with that grammar.\n\n```javascript\nconst Parser = require('tree-sitter');\nconst JavaScript = require('tree-sitter-javascript');\n\nconst parser = new Parser();\nparser.setLanguage(JavaScript);\n```\n\nThen you can parse some source code,\n\n```javascript\nconst sourceCode = 'let x = 1; console.log(x);';\nconst tree = parser.parse(sourceCode);\n```\n\nand inspect the syntax tree.\n\n```javascript\nconsole.log(tree.rootNode.toString());\n\n// (program\n//   (lexical_declaration\n//     (variable_declarator (identifier) (number)))\n//   (expression_statement\n//     (call_expression\n//       (member_expression (identifier) (property_identifier))\n//       (arguments (identifier)))))\n\nconst callExpression = tree.rootNode.child(1).firstChild;\nconsole.log(callExpression);\n\n// {\n//   type: 'call_expression',\n//   startPosition: {row: 0, column: 16},\n//   endPosition: {row: 0, column: 30},\n//   startIndex: 0,\n//   endIndex: 30\n// }\n```\n\nIf your source code *changes*, you can update the syntax tree. This is much faster than the first parse.\n\n```javascript\n// In the code, we replaced 'let' with 'const'.\n// So, we set our old end index to 3, and our new end index to 5.\n// Note that the end index is exclusive.\nconst newSourceCode = 'const x = 1; console.log(x);';\n//                        ^ ^\n// indices:               3 5\n// points:            (0,3) (0,5)\n\ntree.edit({\n  startIndex: 0,\n  oldEndIndex: 3,\n  newEndIndex: 5,\n  startPosition: {row: 0, column: 0},\n  oldEndPosition: {row: 0, column: 3},\n  newEndPosition: {row: 0, column: 5},\n});\n\nconst newTree = parser.parse(newSourceCode, tree);\n```\n\n### Parsing Text From a Custom Data Structure\n\nIf your text is stored in a data structure other than a single string, such as a rope or array, you can parse it by supplying\na callback to `parse` instead of a string:\n\n```javascript\nconst sourceLines = [\n  'let x = 1;',\n  'console.log(x);'\n];\n\nconst tree = parser.parse((index, position) => {\n  let line = sourceLines[position.row];\n  if (line) {\n    return line.slice(position.column);\n  }\n});\n```\n\n### Further Reading\n\nIt's recommended that you read the [Tree-sitter documentation][usage docs] on using parsers to get a higher-level overview\nof the API. Once you're comfortable with the basics, you can explore the [full API documentation](https://tree-sitter.github.io/node-tree-sitter),\nwhich should map closely to the C API, though there are some differences.\n\n[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/node-tree-sitter/ci.yml?logo=github&label=CI\n[cli]: https://github.com/tree-sitter/tree-sitter/tree/master/cli\n[docs]: https://img.shields.io/badge/docs-website-blue\n[npm]: https://img.shields.io/npm/v/tree-sitter?logo=npm\n[grammars]: https://github.com/tree-sitter/tree-sitter/wiki/List-of-parsers\n[javascript]: http://github.com/tree-sitter/tree-sitter-javascript\n[ts docs]: https://tree-sitter.github.io/tree-sitter/creating-parsers\n[usage docs]: https://tree-sitter.github.io/tree-sitter/using-parsers\n","readmeFilename":"README.md","_rev":"1-fc6e92ca51f43da01a55222cbd38db64"}