{"name":"detective-amd","version":"3.0.0","description":"Find all dependencies within a JavaScript file using AMD module syntax","main":"index.js","directories":{"test":"test"},"scripts":{"test":"jscs index.js test/**/*.js bin/*.js && mocha"},"bin":{"detective-amd":"bin/detective-amd.js"},"repository":{"type":"git","url":"git+https://github.com/mrjoelkemp/node-detective-amd.git"},"keywords":["amd","detective","dependencies","ast","static analysis","requirejs","jsx","module"],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com","url":"http://www.mrjoelkemp.com/"},"license":"MIT","bugs":{"url":"https://github.com/mrjoelkemp/node-detective-amd/issues"},"homepage":"https://github.com/mrjoelkemp/node-detective-amd","engines":{"node":">= 6.0"},"dependencies":{"ast-module-types":"^2.3.1","escodegen":"^1.8.0","get-amd-module-type":"^3.0.0","node-source-walk":"^4.0.0"},"devDependencies":{"jscs":"~2.11.0","jscs-preset-mrjoelkemp":"~1.0.0","mocha":"^5.2.0"},"gitHead":"7af454215d5566c97991a1139459ec255b960a93","_id":"detective-amd@3.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.3","_npmUser":{"name":"mrjoelkemp","email":"joel@mrjoelkemp.com"},"dist":{"integrity":"sha512-kOpKHyabdSKF9kj7PqYHLeHPw+TJT8q2u48tZYMkIcas28el1CYeLEJ42Nm+563/Fq060T5WknfwDhdX9+kkBQ==","shasum":"40c8e21e229df8bca1ee2d4b952a7b67b01e2a5a","tarball":"http://registry-npm.ywwl.com/detective-amd/download/detective-amd-3.0.0.tgz","fileCount":4,"unpackedSize":7922,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbkTZ/CRA9TVsSAnZWagAA0g8P/i8Lv3B+v5+HNSjzIg7t\nB2VKNixJPD23KlRxoZUzvS1aODTvqnSRD7gYi33toeCbcOukEeU0DngA+WqA\nAXjaStGTIakGos8hxSAQNIQDYMjShyX1st2NlKQJG59RHiJrSxl2OeIU5dNJ\npykFGbM2a/yWWpKDsbAByu5eXN6AGJYhG8d/1k6FuGmBBAuO/CQRdaP/a81s\nDXxUKI1YwxVm7+/qmWVUtiwPaMqOrFyntPIold6mkY0LQhJkZTvKSZTe0Gw5\n3jKHnG7UBzSV9qrK4xJ02oZS7QiFrTGzh8rW/3DptMacZ6R9E+TnIQvh7A5a\nZky00d5kQvTkEoQO8LE4Mt+2AxwfrzgFuzFTaIgR/SHOYjNeR6qBF29s0DCk\nhsq3GdzarpOtRIekkB3FRTg2fkMFvyoa6piMj7km1AQpDxVDOLfEY8V1zDEK\n83C6DUCtzve6TCUPFh4vXD/Vu8clVFravaRZ34Vc/5fgz9iKAbFGxK+14jox\nhVt/AY1/Z9SuMdQACDQEcRGY3ZCxTmp5L+yXmAZJ9fQ8gbBHGV7UElgmKyO/\nYQbDYJwaFFCKuM2ZsX864ZRZO194wfFsMda/cpP0yI6pfqHaxeINesZkJFxs\nFOv6tGxFmkXgZHWbHDFAx0G4QTQysNzELRex7esyWtTgNA6WwJJ5fvnYSnwa\ng9tZ\r\n=UbKm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC5O7mr9CrZEg0hQJpYrMp4jO4OcF3QucPCEFWhLxpmsgIgMCQbyC3Doegi233rZYc7RIeBSORxnd283B16Ui/lWRg="}],"size":3161,"noattachment":false,"key":"/detective-amd/-/detective-amd-3.0.0.tgz"},"maintainers":[{"name":"mrjoelkemp","email":"joel@mrjoelkemp.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detective-amd_3.0.0_1536243327424_0.7078879203400179"},"_hasShrinkwrap":false,"readme":"# detective-amd\n\n[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-detective-amd/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-detective-amd/actions/workflows/ci.yml?query=branch%3Amain)\n[![npm version](https://img.shields.io/npm/v/detective-amd?logo=npm&logoColor=fff)](https://www.npmjs.com/package/detective-amd)\n[![npm downloads](https://img.shields.io/npm/dm/detective-amd)](https://www.npmjs.com/package/detective-amd)\n\nReturns a list of dependencies for a given JavaScript file or AST using any of the AMD module syntaxes.\n\n*Inspired by substack/node-detective but built for AMD.*\n\n```sh\nnpm install detective-amd\n```\n\n* Supports JSX code via [node-source-walk](https://github.com/dependents/node-source-walk).\n\n## Usage\n\nLet's say we have the following file definitions:\n\n```js\n\n// a.js\ndefine(['./b', './c'], function (b, c) {\n  console.log(b, c);\n});\n\n// b.js\ndefine({\n  name: 'foo'\n});\n\n// c.js\ndefine(function () {\n  return 'bar';\n});\n\n```\n\nHere's how you can grab the list of dependencies of `a.js` **synchronously**.\n\n```js\nconst fs = require('fs');\nconst detective = require('detective-amd');\n\nconst srcA = fs.readFileSync('a.js', 'utf8');\n\n// Pass in the source code or an AST (if you've already parsed the file)\nconsole.log(detective(srcA)); // prints ['./b', './c']\n```\n\nYou may also (optionally) configure the detective via a second object argument `detective(src, options)` that supports the following options:\n\n* `skipLazyLoaded`: (Boolean) whether or not to omit inner requires in the list of extracted dependencies.\n  * Note: this does not affect the REM form since those inner requires are not \"lazily\" fetched.\n\n## Syntax Support\n\n**Supports the 4 forms of AMD module syntax:**\n\n* \"named\": `define('name', [deps], func)`\n* \"dependency list\": `define([deps], func)`\n* \"factory\": `define(func(require))`\n* \"no dependencies\": `define({})`\n\n**Extra forms:**\n\n* \"driver script\" (or entry-point) syntax: `require([deps], func)`\n* \"REM\" (or CommonJS-like) form: `define(function(require, exports, module) {})`.\n\nAlso handles dynamically loaded dependencies (ex: inner requires).\n\n**Supports driver scripts**\n\nYou can also find the dependencies from a script that has a top-level require (an app initialization/driver/entry-point script):\n\n```js\nrequire([\n  './a'\n], function (a) {\n  // My app will get booted up from here\n});\n```\n\n**Expression-based requires**\n\nIf there's a require call that doesn't have a string literal but an expression, a string (escodegen-generated) representation will be returned.\n\nFor example, if `a.js` was of the \"factory\" form and contained a dynamic module name:\n\n```js\n// a.js\n\ndefine(function (require) {\n  // Assume str is some variable that gets set to a string dynamically\n  // const str = ...\n\n  const b = require('./' + str);\n  const c = require('./c');\n\n  console.log(b, c);\n});\n```\n\nThe dependency list will be: `[ '\\'./\\' + str', './c' ]`\n\n* Even though that string representation isn't incredibly useful, it's still added to the list to represent/count that dependency\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1536243327521,"_cnpm_publish_time":1536243327521,"dist-tags":{"latest":"7.0.0"}}