{"name":"falafel","description":"transform the ast on a recursive walk","version":"2.2.5","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","isarray":"^2.0.1"},"devDependencies":{"acorn-jsx":"^5.2.0","covert":"^1.1.0","glob":"^6.0.4","safe-buffer":"^5.2.0","semver":"^6.0.0","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":"f9fb9b0dc307db75eb494bc4d8aace47d38dc4c7","bugs":{"url":"https://github.com/substack/node-falafel/issues"},"homepage":"https://github.com/substack/node-falafel#readme","_id":"falafel@2.2.5","_nodeVersion":"18.1.0","_npmVersion":"8.9.0","dist":{"integrity":"sha512-HuC1qF9iTnHDnML9YZAdCDQwT0yKl/U55K4XSUXqGAA2GLoafFgWRqdAbhWJxXaYD4pyoVxAJ8wH670jMpI9DQ==","shasum":"3ccb4970a09b094e9e54fead2deee64b4a589d56","tarball":"http://registry-npm.ywwl.com/falafel/download/falafel-2.2.5.tgz","fileCount":18,"unpackedSize":69973,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCkXtwCI6y5Uzo89FVXB1Y2Rg74VLsC782LB0OEnfIRTwIhAIqIGehZJP+08HNXQgE351cXjEF5cKqR9sHxOshofs2y"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJie2qDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr4ehAAiJ8LudsWlXJXn35qwBKKsiDgKzNuub6Z+RcqBaUVwsRFy7xT\r\ngE+CCqYQaimNjRtGDshuqH7k/qPGzq2bU+qtvZdNuEaQpSsF0DXYJ8vOUv+X\r\nbfBj0XOU2XnHoU8W2DwLwGET9MJBG49PkoOjGsPQR1fAezKhf8W3Z1n2kZJw\r\nxG38QRaIW0OBmiXfR2FCPV4CMQhjweagf8X7fj/y8yjLKQTJhOYeJ2QxG9S3\r\neqwcWkuxLfuf5T6Tltj8keFS3d14DCY0N963vKlTF/T54AKZpN6YDZP/o6vc\r\nNTVLG0qKMq2/kEcKRImSBIPoJEyGpYsqwkIx7PCxwv5JB5ts28+NfglE/wKj\r\n3pfegntyHhrOfYipmnXUvoZ0qKfhwCjrO8mVX1cRSXDKCjQtz64Lic7DtMlp\r\n0IOsfvHVklLM5hKlKkyrsJCbKnzYPWKzGiAeIftazzMZN7Yi21Ob2K+eAkzQ\r\nIOB/9KA+y1xNvuLAayxcosIkIrX7/YoA1s9HKN02AS+jfbwV/gHfD3g5gX1d\r\nBSgty8PwCYiWzNZeZc2rqAJqMA9Iks9KPqAMZsA262YD9HxtXzxscHQqzuvO\r\npsuRAOM5B2+57q4oBRkJ6SA2ryncsixWSVjiP30z8f34gEd9l2slygIL25xo\r\nnuhoDFuPcbYm+57qSPj/3gJAbHTdZHHYrmk=\r\n=wueG\r\n-----END PGP SIGNATURE-----\r\n","size":56693,"noattachment":false,"key":"/falafel/-/falafel-2.2.5.tgz"},"_npmUser":{"name":"goto-bus-stop","email":"renee@kooi.me"},"maintainers":[{"name":"nanodeath","email":"nanodeath@gmail.com"},{"name":"alltom","email":"tom@alltom.com"},{"name":"eugeneware","email":"eugene@noblesamurai.com"},{"name":"bobthecow","email":"npm@0x7f.us"},{"name":"goto-bus-stop","email":"renee@kooi.me"},{"name":"substack","email":"substack@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/falafel_2.2.5_1652255362972_0.47067497557938"},"_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":1652255363162,"_cnpm_publish_time":1652255363162,"dist-tags":{"latest":"2.2.5"}}