{"_id":"@kristoferbaxter/estree-walker","_rev":"3268870","name":"@kristoferbaxter/estree-walker","description":"Traverse an ESTree-compliant AST","dist-tags":{"latest":"2.0.2"},"maintainers":[{"name":"kristoferbaxter","email":""}],"time":{"modified":"2024-03-21T10:04:25.000Z","created":"2020-01-24T02:49:53.874Z","2.0.2":"2020-04-21T21:23:31.651Z","2.0.0":"2020-01-28T21:56:05.713Z","1.1.0":"2020-01-27T21:18:16.680Z","1.0.2":"2020-01-24T02:49:53.874Z"},"users":{},"author":{"name":"Rich Harris"},"repository":{"type":"git","url":"https://github.com/kristoferbaxter/estree-walker"},"versions":{"2.0.2":{"name":"@kristoferbaxter/estree-walker","description":"Traverse an ESTree-compliant AST","version":"2.0.2","private":false,"author":{"name":"Rich Harris"},"license":"MIT","repository":{"type":"git","url":"https://github.com/kristoferbaxter/estree-walker"},"main":"dist/estree-walker.umd.js","module":"src/estree-walker.mjs","types":"types/index.d.ts","scripts":{"prepublishOnly":"yarn build && yarn test","build":"tsc && rollup -c","test":"mocha"},"devDependencies":{"@types/estree":"0.0.44","mocha":"7.1.1","rollup":"2.7.1","rollup-plugin-sucrase":"2.1.0","typescript":"3.8.3"},"exports":{".":"./src/estree-walker.mjs"},"volta":{"node":"14.0.0","yarn":"1.22.4"},"mocha":{"require":"sucrase/register","spec":"test/test.ts"},"_id":"@kristoferbaxter/estree-walker@2.0.2","dist":{"shasum":"a448a7b298a42c87502c8ab53038d7c0ad2a73a2","size":4592,"noattachment":false,"key":"/@kristoferbaxter/estree-walker/-/@kristoferbaxter/estree-walker-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@kristoferbaxter/estree-walker/download/@kristoferbaxter/estree-walker-2.0.2.tgz"},"maintainers":[{"name":"kristoferbaxter","email":""}],"_npmUser":{"name":"kristoferbaxter","email":"kbax@me.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/estree-walker_2.0.2_1587504211486_0.8917705589278047"},"_hasShrinkwrap":false,"publish_time":1587504211651,"_cnpm_publish_time":1587504211651,"_cnpmcore_publish_time":"2021-12-16T16:55:26.895Z"},"2.0.0":{"name":"@kristoferbaxter/estree-walker","description":"Traverse an ESTree-compliant AST","version":"2.0.0","private":false,"author":{"name":"Rich Harris"},"license":"MIT","repository":{"type":"git","url":"https://github.com/kristoferbaxter/estree-walker"},"main":"dist/estree-walker.umd.js","module":"src/estree-walker.js","types":"types/index.d.ts","scripts":{"prepublishOnly":"npm run build && npm test","build":"tsc && rollup -c","test":"mocha --opts mocha.opts"},"devDependencies":{"@types/estree":"0.0.39","mocha":"^5.2.0","rollup":"^0.67.3","rollup-plugin-sucrase":"^2.1.0","typescript":"^3.6.3"},"_id":"@kristoferbaxter/estree-walker@2.0.0","dist":{"shasum":"52ee40f9f8b59bbf00cac477a777aeb830ea5952","size":4398,"noattachment":false,"key":"/@kristoferbaxter/estree-walker/-/@kristoferbaxter/estree-walker-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@kristoferbaxter/estree-walker/download/@kristoferbaxter/estree-walker-2.0.0.tgz"},"maintainers":[{"name":"kristoferbaxter","email":""}],"_npmUser":{"name":"kristoferbaxter","email":"kbax@me.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/estree-walker_2.0.0_1580248565570_0.085982052766985"},"_hasShrinkwrap":false,"publish_time":1580248565713,"_cnpm_publish_time":1580248565713,"_cnpmcore_publish_time":"2021-12-16T16:55:27.110Z"},"1.1.0":{"name":"@kristoferbaxter/estree-walker","description":"Traverse an ESTree-compliant AST","version":"1.1.0","private":false,"author":{"name":"Rich Harris"},"license":"MIT","repository":{"type":"git","url":"https://github.com/kristoferbaxter/estree-walker"},"main":"dist/estree-walker.umd.js","module":"src/estree-walker.js","types":"types/index.d.ts","scripts":{"prepublishOnly":"npm run build && npm test","build":"tsc && rollup -c","test":"mocha --opts mocha.opts"},"devDependencies":{"@types/estree":"0.0.39","mocha":"^5.2.0","rollup":"^0.67.3","rollup-plugin-sucrase":"^2.1.0","typescript":"^3.6.3"},"_id":"@kristoferbaxter/estree-walker@1.1.0","dist":{"shasum":"4ac5035267f2f170fc4b7d361c477b5a5865e400","size":3654,"noattachment":false,"key":"/@kristoferbaxter/estree-walker/-/@kristoferbaxter/estree-walker-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@kristoferbaxter/estree-walker/download/@kristoferbaxter/estree-walker-1.1.0.tgz"},"maintainers":[{"name":"kristoferbaxter","email":""}],"_npmUser":{"name":"kristoferbaxter","email":"kbax@me.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/estree-walker_1.1.0_1580159896588_0.6757389597821497"},"_hasShrinkwrap":false,"publish_time":1580159896680,"_cnpm_publish_time":1580159896680,"_cnpmcore_publish_time":"2021-12-16T16:55:27.318Z"},"1.0.2":{"name":"@kristoferbaxter/estree-walker","description":"Traverse an ESTree-compliant AST","version":"1.0.2","private":false,"author":{"name":"Rich Harris"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/kristoferbaxter/estree-walker.git"},"main":"dist/estree-walker.umd.js","module":"src/estree-walker.js","types":"types/index.d.ts","scripts":{"prepublishOnly":"npm run build && npm test","build":"tsc && rollup -c","test":"mocha --opts mocha.opts"},"devDependencies":{"@types/estree":"0.0.39","mocha":"^5.2.0","rollup":"^0.67.3","rollup-plugin-sucrase":"^2.1.0","typescript":"^3.6.3"},"gitHead":"ba0e401e00318b8b2d39fd53ebcd26e114eba7f8","bugs":{"url":"https://github.com/kristoferbaxter/estree-walker/issues"},"homepage":"https://github.com/kristoferbaxter/estree-walker#readme","_id":"@kristoferbaxter/estree-walker@1.0.2","_nodeVersion":"12.14.1","_npmVersion":"6.13.4","dist":{"shasum":"7a8cb51a2c451d63ff068c6280564a69a875dda6","size":3311,"noattachment":false,"key":"/@kristoferbaxter/estree-walker/-/@kristoferbaxter/estree-walker-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@kristoferbaxter/estree-walker/download/@kristoferbaxter/estree-walker-1.0.2.tgz"},"maintainers":[{"name":"kristoferbaxter","email":""}],"_npmUser":{"name":"kristoferbaxter","email":"kbax@me.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/estree-walker_1.0.2_1579834193770_0.4614858962411239"},"_hasShrinkwrap":false,"publish_time":1579834193874,"_cnpm_publish_time":1579834193874,"_cnpmcore_publish_time":"2021-12-16T16:55:27.501Z"}},"readme":"# estree-walker\n\nSimple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn).\n\n\n## Installation\n\n```bash\nnpm i estree-walker\n```\n\n\n## Usage\n\n```js\nvar walk = require( 'estree-walker' ).walk;\nvar acorn = require( 'acorn' );\n\nast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn\n\nwalk( ast, {\n  enter: function ( node, parent, prop, index ) {\n    // some code happens\n  },\n  leave: function ( node, parent, prop, index ) {\n  \t// some code happens\n  }\n});\n```\n\nInside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called.\n\nCall `this.replace(new_node)` in either `enter` or `leave` to replace the current node with a new one.\n\nCall `this.remove()` in either `enter` or `leave` to remove the current node.\n\n## Why not use estraverse?\n\nThe ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.\n\nestree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)\n\nNone of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.\n\n\n## License\n\nMIT\n","_attachments":{},"license":"MIT"}