{"name":"detective-amd","version":"3.1.2","description":"Find all dependencies within a JavaScript file using AMD module syntax","main":"index.js","bin":{"detective-amd":"bin/cli.js"},"scripts":{"lint":"eslint bin index.js \"test/*.js\"","mocha":"mocha","test":"npm run lint && npm run mocha"},"repository":{"type":"git","url":"git+https://github.com/dependents/node-detective-amd.git"},"keywords":["amd","detective","dependencies","ast","static analysis","requirejs","jsx","module"],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com"},"license":"MIT","bugs":{"url":"https://github.com/dependents/node-detective-amd/issues"},"homepage":"https://github.com/dependents/node-detective-amd","engines":{"node":">=6.0"},"dependencies":{"ast-module-types":"^3.0.0","escodegen":"^2.0.0","get-amd-module-type":"^3.0.0","node-source-walk":"^4.2.0"},"devDependencies":{"eslint":"^5.16.0","mocha":"^6.2.3"},"gitHead":"be10240578fdbe12fb2df94415e54decbda593ed","_id":"detective-amd@3.1.2","_nodeVersion":"16.14.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-jffU26dyqJ37JHR/o44La6CxtrDf3Rt9tvd2IbImJYxWKTMdBjctp37qoZ6ZcY80RHg+kzWz4bXn39e4P7cctQ==","shasum":"bf55eb5291c218b76d6224a3d07932ef13a9a357","tarball":"http://registry-npm.ywwl.com/detective-amd/download/detective-amd-3.1.2.tgz","fileCount":5,"unpackedSize":9116,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiFNyxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqxbw//VybeQEsX25nyVKx04VTrQZZzd9sIDFoDg2rBqlKTe+qAc0Vc\r\n3NC9SPxci+OCi2PJftPqEYT4h3yYeMKNGsgXIJOn21UxRr/DqUPSVfPOJ6Sb\r\n0Zw3G6742/dPt+McutcQtkYnunt2PcZ3qo37sOfmbxuuLIWNFLUJzMqICYat\r\n43PqQsSxip3X12djLp4z/PuRc3xDlb/dWC/shkDtZ1owlXP0p0NhLXqmsXpA\r\n0VyKPWEzQyqKk6rQGkNTjbNcmkxNxl/EXUigFNnmdkLQwI78NvN28wqNBjpy\r\nAGZr0ksLhdrZwmLlQvNYUb5Q9T7D6iLJG4lrOiOe2L9P4I4Qrl0ZT/R3lJdl\r\nIBC6Sp9VGlSidmIRnrahBKYTTMpHOnWX7dh1aUx9occaqG5w9ZP0WwGE4ztU\r\nlYBkwdsqFNMIzSmt/xcEoEJ4JROm/+Hnkpmo66Gs516KP7BPugXWCiu9BQ3g\r\nTM726t23mgNORvenTUWxks26kz9eHWdHm5DsVyvyKIAtOLBqCT4cLRvc1gE0\r\nwgOfiscs8C4jBwqOyq4kfGpO7PZiTGc0mLr95a5QpyjKhjAy3g7wgl5P438K\r\nq032qQSnOXYd1slUfn4icndTnzxHKQ50nS07rel2p1v0k7KqwKTT9ixgmHO+\r\naMM7XQqCjOnMRYRho+Rt6hNxjrIYvj0VL9g=\r\n=3eLf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCkm2qBKmgY697GbIiMwZm5eft6TQ9kAFcN+zfLmaE8hQIgWoeyMTiMZVfvbZgJpmknths7HVVrY79/6GlagoW6Hqc="}],"size":3801,"noattachment":false,"key":"/detective-amd/-/detective-amd-3.1.2.tgz"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"directories":{},"maintainers":[{"name":"mrjoelkemp","email":"mrjoelkemp@gmail.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detective-amd_3.1.2_1645534385772_0.6798644844881196"},"_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":1645534385879,"_cnpm_publish_time":1645534385879,"dist-tags":{"latest":"7.0.0"}}