{"name":"amdetective","version":"0.2.0","description":"Like node-detective, but for AMD/r.js files. Finds all calls to `require()` in AMD modules by walking the AST.","main":"index.js","scripts":{"test":"mocha -R spec ./test/test.js"},"keywords":["require","source","analyze","ast","amd","detective"],"repository":{"type":"git","url":"git://github.com/mixu/amdetective.git"},"author":{"name":"Mikito Takada","email":"mikito.takada@gmail.com","url":"http://mixu.net/"},"license":"BSD","dependencies":{"esprima":"~2.7.0"},"gitHead":"64caca7211aa0fbef5417d0ee1a4fcb6defd0440","bugs":{"url":"https://github.com/mixu/amdetective/issues"},"homepage":"https://github.com/mixu/amdetective#readme","_id":"amdetective@0.2.0","_shasum":"a7a02a80ed10408ae83931242d697a4f6616ca13","_from":".","_npmVersion":"2.11.2","_nodeVersion":"0.12.6","_npmUser":{"name":"mixu","email":"mixu@mixu.net"},"dist":{"shasum":"a7a02a80ed10408ae83931242d697a4f6616ca13","tarball":"http://registry-npm.ywwl.com/amdetective/download/amdetective-0.2.0.tgz","integrity":"sha512-TgrIdqW94il0kJYfbAobjaa1gNjkNM6JyKbl0z8eBBk2jE8q0v422TRzgUP4J9NEJSM0jcmElHKtvfeWGC1Qdw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCfS/Lm5R2/jlOP36c1unLuTRy/4kR2tl2t0y5jqtfKkwIhAI5KDV1Qzwd2kjglkNj2L52tx3seC/vP9yitcd09WEBE"}],"size":12322,"noattachment":false,"key":"/amdetective/-/amdetective-0.2.0.tgz"},"maintainers":[{"name":"mixu","email":"mixu@mixu.net"}],"directories":{},"readme":"# amdetective\n\nFind all calls to `require()` in AMD modules by walking the AST.\n\nThis module uses code extracted from [r.js](https://github.com/jrburke/r.js) rather than trying to write it's own version of r.js parsing. It depends on esprima (but not r.js).\n\n# Install\n\n```\nnpm install amdetective\n```\n\n# example\n\nFirst, create `detect.js` which is just a four line CLI wrapper around `amdetective`:\n\n````js\nvar fs = require('fs'),\n    amdetective = require('amdetective');\n\nconsole.log('Reading file from first argument: ' + process.argv[2]);\nconsole.log(amdetective(fs.readFileSync(process.argv[2]).toString()));\n````\n\nNow, let's run it on a bunch of examples to see some output. You can also run this command on your own files to get more realistic examples.\n\n## Definition Functions with Dependencies (simple.js)\n\n````js\nrequire(['module1', 'path/to/module2'], function(a, b){\n  // ...\n});\n````\n\nRunning `node detect.js simple.js` produces:\n\n````\nReading file from first argument: simple.js\n[ 'module1', 'path/to/module2' ]\n````\n\n## Simplified CommonJS Wrapper (simple2.js)\n\n````js\ndefine(function(require) {\n  var a = require('some/file'),\n      b = require('json!foo/bar');\n  // ...\n});\n````\n\nRunning `node detect.js simple2.js` produces:\n\n````\nReading file from first argument: simple2.js\n[ 'require', 'some/file', 'json!foo/bar' ]\n````\n\n## Named module (named.js)\n\n````js\ndefine(\"foo/title\",\n    [\"my/cart\", \"my/inventory\"],\n    function(cart, inventory) {\n   }\n);\n````\n\nRunning `node detect.js simple2.js` produces:\n\n````\nReading file from first argument: named.js\n[ { name: 'foo/title', deps: [ 'my/cart', 'my/inventory' ] } ]\n````\n\nNote how named modules are treated differently - this is just something that the underlying resolution code does so be prepared to deal with it.\n\n# Methods\n\n## amdetective(src, opts)\n\nGiven some source body `src`, return an array of all the `require()` call arguments detected by AMD/r.js.\n\nThe options parameter `opts` is passed along to `parse.recurse()` in [lib/parse.js](https://github.com/mixu/amdetective/blob/master/lib/parse.js#L196). This is normally the build config options if it is passed.\n\n# License\n\nBSD\n","publish_time":1447703406153,"_cnpm_publish_time":1447703406153,"dist-tags":{"latest":"0.3.0"}}