{"_id":"@anterior/tree-sitter","_rev":"2-4cf44d002bd42b0a0b95e1819bc82a72","name":"@anterior/tree-sitter","dist-tags":{"latest":"0.25.1"},"versions":{"0.0.1":{"name":"@anterior/tree-sitter","version":"0.0.1","keywords":["incremental","parsing","tree-sitter"],"author":{"name":"Max Brunsfeld","email":"maxbrunsfeld@gmail.com"},"license":"MIT","_id":"@anterior/tree-sitter@0.0.1","maintainers":[{"name":"ben-anterior","email":"ben@anterior.com"},{"name":"robinlewis","email":"robin.lewis@anterior.com"},{"name":"shun-anterior","email":"shun.ueda@anterior.com"},{"name":"austin.chen.anterior","email":"austin.chen@anterior.com"}],"contributors":[{"name":"Segev Finer","email":"segev208@gmail.com"},{"name":"Boris Verkhovskiy","email":"boris.verk@gmail.com"}],"homepage":"https://github.com/tree-sitter/node-tree-sitter#readme","bugs":{"url":"https://github.com/tree-sitter/node-tree-sitter/issues"},"dist":{"shasum":"54b062263cf6ca354910aa1cabb5052d60297573","tarball":"https://registry.npmjs.org/@anterior/tree-sitter/-/tree-sitter-0.0.1.tgz","fileCount":26,"integrity":"sha512-dQFgT7bwsFumFAIYHB9BPm8LvLfXJJoJH3IeUiv7aXD7UPLCjUj8XP0VPdLacw69oEcD0k/se5DwAaGLhgtJ7Q==","signatures":[{"sig":"MEUCIQDG7+KcNh9WCPr6F+ACQJVUHEqhLD/sgx9vbuUAZVuB6QIgfJXRrcR2+JpUQkGO3hshM/535GH8z+pN+hIlCGCq2to=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":172901},"main":"index.js","types":"tree-sitter.d.ts","gitHead":"0680e2525c15479b5f65310403f3e68a513636ae","scripts":{"docs":"typedoc --out docs/api tree-sitter.d.ts --readme README.md","test":"node -e \"require('child_process').spawnSync('node', ['--test', ...require('glob').sync('test/**/*.js')], {stdio:'inherit'})\"","build":"prebuildify --napi --strip","install":"node-gyp-build","rebuild":"node-gyp rebuild"},"_npmUser":{"name":"robinlewis","email":"robin.lewis@anterior.com"},"repository":{"url":"git+ssh://git@github.com/tree-sitter/node-tree-sitter.git","type":"git"},"_npmVersion":"10.9.7","description":"Node.js bindings to the Tree-sitter parsing library","directories":{},"_nodeVersion":"22.22.2","dependencies":{"node-addon-api":"^8.5.0","node-gyp-build":"^4.8.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tmp":"^0.2.5","glob":"^13.0.0","typedoc":"^0.28.15","node-gyp":"^12.1.0","@types/tmp":"^0.2.6","typescript":"^5.9.3","@types/node":"^25.0.3","prebuildify":"^6.0.1","tree-sitter-c":"^0.24.1","tree-sitter-html":"^0.23.2","tree-sitter-java":"^0.23.5","tree-sitter-json":"^0.24.8","tree-sitter-ruby":"^0.23.1","tree-sitter-rust":"^0.24.0","tree-sitter-python":"^0.25.0","tree-sitter-javascript":"^0.25.0","tree-sitter-embedded-template":"^0.25.0","typedoc-plugin-rename-defaults":"^0.7.3"},"_npmOperationalInternal":{"tmp":"tmp/tree-sitter_0.0.1_1782498037279_0.7041541841430432","host":"s3://npm-registry-packages-npm-production"}},"0.25.1":{"name":"@anterior/tree-sitter","version":"0.25.1","description":"Node.js bindings to the Tree-sitter parsing library","repository":{"type":"git","url":"git+https://github.com/anteriorcore/node-tree-sitter.git"},"publishConfig":{"access":"public"},"license":"MIT","author":{"name":"Max Brunsfeld","email":"maxbrunsfeld@gmail.com"},"maintainers":[{"name":"ben-anterior","email":"ben@anterior.com"},{"name":"robinlewis","email":"robin.lewis@anterior.com"},{"name":"shun-anterior","email":"shun.ueda@anterior.com"},{"name":"austin.chen.anterior","email":"austin.chen@anterior.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":{"node-addon-api":"^8.5.0","node-gyp-build":"^4.8.4"},"devDependencies":{"@types/node":"^25.0.3","@types/tmp":"^0.2.6","glob":"^13.0.0","node-gyp":"^12.1.0","prebuildify":"^6.0.1","tmp":"^0.2.5","tree-sitter-c":"^0.24.1","tree-sitter-embedded-template":"^0.25.0","tree-sitter-html":"^0.23.2","tree-sitter-java":"^0.23.5","tree-sitter-javascript":"^0.25.0","tree-sitter-json":"^0.24.8","tree-sitter-python":"^0.25.0","tree-sitter-ruby":"^0.23.1","tree-sitter-rust":"^0.24.0","typedoc":"^0.28.15","typedoc-plugin-rename-defaults":"^0.7.3","typescript":"^5.9.3"},"scripts":{"docs":"typedoc --out docs/api tree-sitter.d.ts --readme README.md","install":"node-gyp-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'})\""},"gitHead":"6610d543baa03573a83abe4fc3a5ed0c91a95ac9","_id":"@anterior/tree-sitter@0.25.1","bugs":{"url":"https://github.com/anteriorcore/node-tree-sitter/issues"},"homepage":"https://github.com/anteriorcore/node-tree-sitter#readme","_nodeVersion":"24.17.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-FwMxqNW+OVl1aNpJMCKx+ezR0vehXd4YR8WcX6vcfzIv7Wm3nNvXfCo7fLxViQnqv+R10ncrjbJIpetZ0xghwA==","shasum":"8dfa750e3c5acac8cea7cbb28d9527ce7369c9e9","tarball":"https://registry.npmjs.org/@anterior/tree-sitter/-/tree-sitter-0.25.1.tgz","fileCount":80,"unpackedSize":4454552,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@anterior%2ftree-sitter@0.25.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC9aO9YFhmqmF0dmOYCiw362ueoV/gX208+hEF+jiURHAIgF+9rDuiq2hre0bdmkEKjwFTFmMjclfXwqvW4yKcxaNg="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:fa62564d-f2e3-4a76-be24-e1d8d9609f42"}},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tree-sitter_0.25.1_1782510896423_0.4548405515001317"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-26T18:20:37.081Z","modified":"2026-06-26T21:54:56.940Z","0.0.1":"2026-06-26T18:20:37.465Z","0.25.1":"2026-06-26T21:54:56.642Z"},"bugs":{"url":"https://github.com/anteriorcore/node-tree-sitter/issues"},"author":{"name":"Max Brunsfeld","email":"maxbrunsfeld@gmail.com"},"license":"MIT","homepage":"https://github.com/anteriorcore/node-tree-sitter#readme","keywords":["incremental","parsing","tree-sitter"],"repository":{"type":"git","url":"git+https://github.com/anteriorcore/node-tree-sitter.git"},"description":"Node.js bindings to the Tree-sitter parsing library","contributors":[{"name":"Segev Finer","email":"segev208@gmail.com"},{"name":"Boris Verkhovskiy","email":"boris.verk@gmail.com"}],"maintainers":[{"name":"ben-anterior","email":"ben@anterior.com"},{"name":"robinlewis","email":"robin.lewis@anterior.com"},{"name":"shun-anterior","email":"shun.ueda@anterior.com"},{"name":"austin.chen.anterior","email":"austin.chen@anterior.com"}],"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"}