{"_id":"ast-transform","_rev":"92659","name":"ast-transform","description":"Convenience wrapper for performing AST transformations with browserify transform streams","dist-tags":{"latest":"0.0.0"},"maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}],"time":{"modified":"2021-06-03T10:30:41.000Z","created":"2014-02-27T04:57:40.964Z","0.0.0":"2014-02-27T04:57:40.964Z"},"users":{"joaocunha":true},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://hughsk.io/"},"repository":{"type":"git","url":"git://github.com/hughsk/ast-transform"},"versions":{"0.0.0":{"name":"ast-transform","description":"Convenience wrapper for performing AST transformations with browserify transform streams","version":"0.0.0","main":"index.js","dependencies":{"through":"~2.3.4","esprima":"~1.0.4","escodegen":"~1.2.0"},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://hughsk.io/"},"license":"MIT","repository":{"type":"git","url":"git://github.com/hughsk/ast-transform"},"bugs":{"url":"https://github.com/hughsk/ast-transform/issues"},"homepage":"https://github.com/hughsk/ast-transform","keywords":["ast","transform","browserify","stream"],"_id":"ast-transform@0.0.0","dist":{"shasum":"74944058887d8283e189d954600947bc98fe0062","size":2263,"noattachment":false,"key":"/ast-transform/-/ast-transform-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/ast-transform/download/ast-transform-0.0.0.tgz"},"_from":".","_npmVersion":"1.4.2","_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}],"directories":{},"publish_time":1393477060964,"_hasShrinkwrap":false,"_cnpm_publish_time":1393477060964}},"readme":"# ast-transform [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/ast-transform&title=ast-transform&description=hughsk/ast-transform%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #\n\nConvenience wrapper for performing AST transformations with\n[browserify](http://browserify.org/) transform streams. Note that it doesn't\nhandle source maps nicely, though pull requests are welcome!\n\n## Usage ##\n\n[![ast-transform](https://nodei.co/npm/ast-transform.png?mini=true)](https://nodei.co/npm/ast-transform)\n\n### `ast(transform[, opts])` ###\n\nWhere `transform` is a function that takes a filename and returns a function,\ne.g.:\n\n``` javascript\nvar replace = require('replace-method')\nvar ast = require('ast-transform')\nvar path = require('path')\n\nmodule.exports = ast(function (file) {\n  if (path.extname(file) !== '.js') return\n\n  return function(ast, done) {\n    // replace require calls with\n    // strings for some reason\n    replace(ast)(['require'], function(node) {\n      return { type: 'Literal', value: 'replaced!' }\n    })\n\n    done()\n  }\n})\n```\n\nNote that you can return a falsey value instead of a function to bail the\nstream early and avoid the parse/deparse overhead. Here's an example of using\nthe above with browserify:\n\n``` javascript\nvar browserify = require('browserify')\nvar example = require('./example')\nvar fs = require('fs')\n\nbrowserify('./index.js')\n  .transform(example)\n  .bundle()\n  .pipe(fs.createWriteStream(__filename + '/bundle.js'))\n```\n\n## License ##\n\nMIT. See [LICENSE.md](http://github.com/hughsk/ast-transform/blob/master/LICENSE.md) for details.\n","_attachments":{},"homepage":"https://github.com/hughsk/ast-transform","bugs":{"url":"https://github.com/hughsk/ast-transform/issues"},"license":"MIT"}