{"name":"acorn-walk","description":"ECMAScript (ESTree) AST walker","homepage":"https://github.com/acornjs/acorn","main":"dist/walk.js","types":"dist/walk.d.ts","module":"dist/walk.mjs","exports":{".":[{"import":"./dist/walk.mjs","require":"./dist/walk.js","default":"./dist/walk.js"},"./dist/walk.js"],"./package.json":"./package.json"},"version":"8.3.5","engines":{"node":">=0.4.0"},"dependencies":{"acorn":"^8.11.0"},"maintainers":[{"name":"marijn","email":"marijn@haverbeke.berlin"},{"name":"adrianheine","email":"mail@adrianheine.de"},{"name":"rreverser","email":"me@rreverser.com"}],"repository":{"type":"git","url":"git+https://github.com/acornjs/acorn.git"},"scripts":{"prepare":"cd ..; npm run build:walk"},"license":"MIT","gitHead":"e4baf9eebe3dd9b2df6ccdfa2127ebfb423b2b8d","_id":"acorn-walk@8.3.5","bugs":{"url":"https://github.com/acornjs/acorn/issues"},"_nodeVersion":"22.20.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-HEHNfbars9v4pgpW6SO1KSPkfoS0xVOM/9UzkJltjlsHZmJasxg8aXkuZa7SMf8vKGIBhpUsPluQSqhJFCqebw==","shasum":"8a6b8ca8fc5b34685af15dabb44118663c296496","tarball":"http://registry-npm.ywwl.com/acorn-walk/download/acorn-walk-8.3.5.tgz","fileCount":8,"unpackedSize":53765,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEUhV3U/g7O2v+TvAepjd50oaVy4CCtTiBIv/KpxGC4SAiEA8yRp4mnVr/QkGSRwDWkjfGBDLn/obgIEaTF9ZQHfAFk="}],"size":9793,"noattachment":false,"key":"/acorn-walk/-/acorn-walk-8.3.5.tgz"},"_npmUser":{"name":"marijn","email":"marijn@haverbeke.berlin"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/acorn-walk_8.3.5_1771513387951_0.3543005254172735"},"_hasShrinkwrap":false,"readme":"# Acorn AST walker\n\nAn abstract syntax tree walker for the\n[ESTree](https://github.com/estree/estree) format.\n\n## Community\n\nAcorn is open source software released under an\n[MIT license](https://github.com/acornjs/acorn/blob/master/acorn-walk/LICENSE).\n\nYou are welcome to\n[report bugs](https://github.com/acornjs/acorn/issues) or create pull\nrequests on [github](https://github.com/acornjs/acorn).\n\n## Installation\n\nThe easiest way to install acorn is from [`npm`](https://www.npmjs.com/):\n\n```sh\nnpm install acorn-walk\n```\n\nAlternately, you can download the source and build acorn yourself:\n\n```sh\ngit clone https://github.com/acornjs/acorn.git\ncd acorn\nnpm install\n```\n\n## Interface\n\nAn algorithm for recursing through a syntax tree is stored as an\nobject, with a property for each tree node type holding a function\nthat will recurse through such a node. There are several ways to run\nsuch a walker.\n\n**simple**`(node, visitors, base, state)` does a 'simple' walk over a\ntree. `node` should be the AST node to walk, and `visitors` an object\nwith properties whose names correspond to node types in the [ESTree\nspec](https://github.com/estree/estree). The properties should contain\nfunctions that will be called with the node object and, if applicable\nthe state at that point. The last two arguments are optional. `base`\nis a walker algorithm, and `state` is a start state. The default\nwalker will simply visit all statements and expressions and not\nproduce a meaningful state. (An example of a use of state is to track\nscope at each point in the tree.)\n\n```js\nimport * as acorn from \"acorn\"\nimport * as walk from \"acorn-walk\"\n\nwalk.simple(acorn.parse(\"let x = 10\"), {\n  Literal(node) {\n    console.log(`Found a literal: ${node.value}`)\n  }\n})\n```\n\n**ancestor**`(node, visitors, base, state)` does a 'simple' walk over\na tree, building up an array of ancestor nodes (including the current node)\nand passing the array to the callbacks as a third parameter.\n\n```js\nimport * as acorn from \"acorn\"\nimport * as walk from \"acorn-walk\"\n\nwalk.ancestor(acorn.parse(\"foo('hi')\"), {\n  Literal(_node, _state, ancestors) {\n    console.log(\"This literal's ancestors are:\", ancestors.map(n => n.type))\n  }\n})\n```\n\n**recursive**`(node, state, functions, base)` does a 'recursive'\nwalk, where the walker functions are responsible for continuing the\nwalk on the child nodes of their target node. `state` is the start\nstate, and `functions` should contain an object that maps node types\nto walker functions. Such functions are called with `(node, state, c)`\narguments, and can cause the walk to continue on a sub-node by calling\nthe `c` argument on it with `(node, state)` arguments. The optional\n`base` argument provides the fallback walker functions for node types\nthat aren't handled in the `functions` object. If not given, the\ndefault walkers will be used.\n\n**make**`(functions, base)` builds a new walker object by using the\nwalker functions in `functions` and filling in the missing ones by\ntaking defaults from `base`.\n\n**full**`(node, callback, base, state)` does a 'full' walk over a\ntree, calling the callback with the arguments (node, state, type) for\neach node\n\n**fullAncestor**`(node, callback, base, state)` does a 'full' walk\nover a tree, building up an array of ancestor nodes (including the\ncurrent node) and passing the array to the callbacks as a third\nparameter.\n\n```js\nimport * as acorn from \"acorn\"\nimport * as walk from \"acorn-walk\"\n\nwalk.full(acorn.parse(\"1 + 1\"), node => {\n  console.log(`There's a ${node.type} node at ${node.ch}`)\n})\n```\n\n**findNodeAt**`(node, start, end, test, base, state)` tries to locate\na node in a tree at the given start and/or end offsets, which\nsatisfies the predicate `test`. `start` and `end` can be either `null`\n(as wildcard) or a number. `test` may be a string (indicating a node\ntype) or a function that takes `(nodeType, node)` arguments and\nreturns a boolean indicating whether this node is interesting. `base`\nand `state` are optional, and can be used to specify a custom walker.\nNodes are tested from inner to outer, so if two nodes match the\nboundaries, the inner one will be preferred.\n\n**findNodeAround**`(node, pos, test, base, state)` is a lot like\n`findNodeAt`, but will match any node that exists 'around' (spanning)\nthe given position.\n\n**findNodeAfter**`(node, pos, test, base, state)` is similar to\n`findNodeAround`, but will match all nodes *after* the given position\n(testing outer nodes before inner nodes).\n","publish_time":1771513388080,"_cnpm_publish_time":1771513388080,"dist-tags":{"latest":"8.3.5"}}