{"name":"falafel","description":"transform the ast on a recursive walk","version":"2.2.2","repository":{"type":"git","url":"git://github.com/substack/node-falafel.git"},"main":"index.js","keywords":["ast","burrito","source","syntax","traversal","tree"],"directories":{"example":"example","test":"test"},"scripts":{"coverage":"covert test/*.js","test":"node --harmony test/bin/run.js test/*.js"},"dependencies":{"acorn":"^7.1.1","foreach":"^2.0.5","isarray":"0.0.1","object-keys":"^1.0.6"},"devDependencies":{"acorn-jsx":"^5.2.0","covert":"^1.1.0","glob":"^6.0.4","tape":"^4.0.0"},"engines":{"node":">=0.4.0"},"license":"MIT","author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"testling":{"browsers":{"chrome":["20.0"],"firefox":["10.0","15.0"],"iexplore":["6.0","7.0","8.0","9.0"],"opera":["12.0"],"safari":["5.1"]},"files":"test/*.js"},"gitHead":"6d1c4f0ded837196a1db1e8db0588fa7b808a286","bugs":{"url":"https://github.com/substack/node-falafel/issues"},"homepage":"https://github.com/substack/node-falafel#readme","_id":"falafel@2.2.2","_nodeVersion":"13.10.1","_npmVersion":"6.14.2","dist":{"integrity":"sha512-FpofwPn8aUkwyBOULXbb8insfa7iq3YasM+tJPVrxYBXIEr/0mfV/zGd64d9NzXLKrPZCfYJWTPCR3LBOPXbhA==","shasum":"55e7c82d7db4632d8d8dcb5a7aad135b2c94c4f3","tarball":"http://registry-npm.ywwl.com/falafel/download/falafel-2.2.2.tgz","fileCount":16,"unpackedSize":17735,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZqXJCRA9TVsSAnZWagAADeUP/3dU2veXL7W0D1AkzLnl\n071dl8TsVGG8cLvtu9I0zuq1bgzr9ZGl5zPe5OtDxMo17JzSrdT3fnlZ2A37\nwIxokl8hWX36Dzx4mxpvj12atLukM3b1gDdf9r/Yf+dMbGgDAuU8fPnOig09\ns/HZ7hQo5w98+wCt0lSfNX7CnVDCaXrXjGRI1Koprl/EPTrk/+QWa7YP9QcQ\naDCOL9AbZJbOs96cnZ5OTRExSIPsexLHmB8Srh0zgNX9kHqEg6y/3N7o+hUJ\ngXgCpMx2cSp1z0s4zWGJWvuSLd7DQjU/y6rzQZUc3iT+9CzSteMRgU//0Kgw\nBays+ZJukpudppZm3RrOIegoKO9p6NkcOrzbwFCHIiEGVUhLeck1FRlEBVin\nUEtddJC8N1tRMxnzxy/QzjeiiD5iQc4HfSqkq91rIGwUz2Rfe+ET5fM24lUy\nCg6+rHt4oOkQhkwcQKkgYyzL+9V7kubYS1C9YRkPumqSlb2Yayj50YbiG5AD\nct9G06sJdSJtpqroPMzQ5bpzl1Nby2RxBrPfMpxcQ+dpk5qVAqCLaMuxpEsO\n86YjTS2uHj872WSkdaSu2nFRfx7IokxHP5xRJOpj9hxtVAVxVZY2KY3Pu6mz\nPBfswZsdw69hpe7TV26khv387TqZOj0dYRe0H6u9s7Lx7Ct0GVzcvFVg7Q8B\nYxNS\r\n=hU/I\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD7GYBvlqcB4mdalx7q2wVhOAWixHBePhHtAi0xZWSVFgIhAN/c1Js2WH3We7ITbSpE2m7XWp8agBlKoV8YUnK+xw55"}],"size":4748,"noattachment":false,"key":"/falafel/-/falafel-2.2.2.tgz"},"maintainers":[{"email":"tom@alltom.com","name":"alltom"},{"email":"npm@0x7f.us","name":"bobthecow"},{"email":"eugene@noblesamurai.com","name":"eugeneware"},{"email":"renee@kooi.me","name":"goto-bus-stop"},{"email":"nanodeath@gmail.com","name":"nanodeath"},{"email":"substack@gmail.com","name":"substack"}],"_npmUser":{"name":"goto-bus-stop","email":"renee@kooi.me"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/falafel_2.2.2_1583785417525_0.886499274255651"},"_hasShrinkwrap":false,"readme":"# falafel\n\nTransform the [ast](http://en.wikipedia.org/wiki/Abstract_syntax_tree) on a\nrecursive walk.\n\n[![browser support](http://ci.testling.com/substack/node-falafel.png)](http://ci.testling.com/substack/node-falafel)\n\n[![build status](https://github.com/substack/node-falafel/workflows/Node%20CI/badge.svg?branch=master)](https://github.com/substack/node-falafel/actions)\n\nThis modules uses [acorn](https://npmjs.org/package/acorn) to create an AST from\nsource code.\n\n![falafel döner](./falafel.png)\n\n# example\n\n## array.js\n\nPut a function wrapper around all array literals.\n\n``` js\nvar falafel = require('falafel');\n\nvar src = '(' + function () {\n    var xs = [ 1, 2, [ 3, 4 ] ];\n    var ys = [ 5, 6 ];\n    console.dir([ xs, ys ]);\n} + ')()';\n\nvar output = falafel(src, function (node) {\n    if (node.type === 'ArrayExpression') {\n        node.update('fn(' + node.source() + ')');\n    }\n});\nconsole.log(output);\n```\n\noutput:\n\n```\n(function () {\n    var xs = fn([ 1, 2, fn([ 3, 4 ]) ]);\n    var ys = fn([ 5, 6 ]);\n    console.dir(fn([ xs, ys ]));\n})()\n```\n\n# methods\n\n``` js\nvar falafel = require('falafel')\n```\n\n## falafel(src, opts={}, fn)\n\nTransform the string source `src` with the function `fn`, returning a\nstring-like transformed output object.\n\nFor every node in the ast, `fn(node)` fires. The recursive walk is a\npost-order traversal, so children get called before their parents.\n\nPerforming a post-order traversal makes it easier to write nested transforms since\ntransforming parents often requires transforming all its children first.\n\nThe return value is string-like (it defines `.toString()` and `.inspect()`) so\nthat you can call `node.update()` asynchronously after the function has\nreturned and still capture the output.\n\nInstead of passing a `src` you can also use `opts.source`.\n\nAll of the `opts` will be passed directly to\n[acorn](https://npmjs.org/package/acorn).\n\n## custom parser\n\nYou may pass in an instance of acorn to the opts as `opts.parser` to use that\nversion instead of the version of acorn packaged with this library.\n\n```js\nvar acorn = require('acorn-jsx');\n\nfalafel(src, {parser: acorn, plugins: { jsx: true }}, function(node) {\n  // this will parse jsx\n});\n```\n\n# nodes\n\nAside from the regular [acorn](https://npmjs.org/package/acorn) data, you can also call\nsome inserted methods on nodes.\n\nAside from updating the current node, you can also reach into sub-nodes to call\nupdate functions on children from parent nodes.\n\n## node.source()\n\nReturn the source for the given node, including any modifications made to\nchildren nodes.\n\n## node.update(s)\n\nTransform the source for the present node to the string `s`.\n\nNote that in `'ForStatement'` node types, there is an existing subnode called\n`update`. For those nodes all the properties are copied over onto the\n`node.update()` function.\n\n## node.parent\n\nReference to the parent element or `null` at the root element.\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install falafel\n```\n\n# license\n\nMIT\n","publish_time":1583785417643,"_cnpm_publish_time":1583785417643,"dist-tags":{"latest":"2.2.5"}}