{"name":"module-definition","version":"6.0.1","description":"Determines if a file is using a CommonJS or AMD module definition","main":"index.js","bin":{"module-definition":"bin/cli.js"},"scripts":{"lint":"xo","fix":"xo --fix","mocha":"mocha","test":"npm run lint && npm run mocha","test:ci":"c8 npm run mocha"},"repository":{"type":"git","url":"git+https://github.com/dependents/module-definition.git"},"keywords":[],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com","url":"https://mrjoelkemp.com/"},"license":"MIT","bugs":{"url":"https://github.com/dependents/module-definition/issues"},"homepage":"https://github.com/dependents/module-definition","engines":{"node":">=18"},"dependencies":{"ast-module-types":"^6.0.1","node-source-walk":"^7.0.1"},"devDependencies":{"c8":"^10.1.3","memfs":"^4.17.0","mocha":"^11.1.0","unionfs":"^4.5.4","xo":"^0.60.0"},"xo":{"space":true,"ignores":["test/fixtures/*"],"rules":{"arrow-body-style":"off","capitalized-comments":"off","comma-dangle":["error","never"],"curly":["error","multi-line"],"operator-linebreak":["error","after"],"object-curly-spacing":["error","always"],"prefer-template":"error","space-before-function-paren":["error","never"],"unicorn/no-anonymous-default-export":"off","unicorn/prefer-module":"off","unicorn/prefer-node-protocol":"off","unicorn/prefer-string-slice":"off","unicorn/prefer-top-level-await":"off","unicorn/prevent-abbreviations":"off"}},"_id":"module-definition@6.0.1","gitHead":"91fcc00a548da95fe5680d5245ca6d9cdccd6e7d","_nodeVersion":"20.18.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-FeVc50FTfVVQnolk/WQT8MX+2WVcDnTGiq6Wo+/+lJ2ET1bRVi3HG3YlJUfqagNMc/kUlFSoR96AJkxGpKz13g==","shasum":"47e73144cc5a9aa31f3380166fddf8e962ccb2e4","tarball":"http://registry-npm.ywwl.com/module-definition/download/module-definition-6.0.1.tgz","fileCount":5,"unpackedSize":7623,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIETtSaBu+GwM+FII1zkDGCAosyjZkEaC7Xc3nEM7mf7zAiEAk8zfVada8/XnBoV9UyCqXfeoGEE1GtFeuxnqnmI9OXA="}],"size":3104,"noattachment":false,"key":"/module-definition/-/module-definition-6.0.1.tgz"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/module-definition_6.0.1_1738416202529_0.24706725982685884"},"_hasShrinkwrap":false,"readme":"# module-definition\n\n[![CI](https://img.shields.io/github/actions/workflow/status/dependents/module-definition/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/module-definition/actions/workflows/ci.yml?query=branch%3Amain)\n[![npm version](https://img.shields.io/npm/v/module-definition?logo=npm&logoColor=fff)](https://www.npmjs.com/package/module-definition)\n[![npm downloads](https://img.shields.io/npm/dm/module-definition)](https://www.npmjs.com/package/module-definition)\n\nDetermines the module definition type (CommonJS, AMD, ES6, or none) for a given JavaScript file\nby walking through the AST.\n\n```sh\nnpm install module-definition\n```\n\n## Usage\n\n```js\nconst getModuleType = require('module-definition');\n\n// Async\ngetModuleType('myscript.js', (error, type) => {\n  console.log(type);\n});\n\n// Sync\nlet type = getModuleType.sync('myscript.js');\nconsole.log(type);\n\n// From source (string or an AST)\ntype = getModuleType.fromSource('define({foo: \"foo\"});');\nconsole.log(type);\n```\n\nPasses one of the following strings to the given callback or returns the string in sync API:\n\n* amd\n* commonjs\n* es6\n* none\n\nYou may also pass an AST to `fromSource` to avoid an internal parsing of the source.\n\nWhen specifying a filename, using the sync or async API, you can also provide an `options` object with an alternative `fs` implementation used to read the source file with.\n\n```js\nconst myFs = GetFs();\nconst options = { fileSystem: myFs };\n\n// Async\ngetModuleType('myscript.js', (error, type) => {\n  console.log(type);\n}, options);\n\n// Sync\nconst type = getModuleType.sync('myscript.js', options);\n```\n\n## CLI\n\n*Assumes a global install module-definition with `npm install -g module-definition`*\n\n```sh\nmodule-definition filename\n```\n\n### License\n\n[MIT](LICENSE)\n","publish_time":1738416202716,"maintainers":[{"name":"pahen","email":"patrik.henningsson@gmail.com"},{"name":"mrjoelkemp","email":"mrjoelkemp@gmail.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_cnpm_publish_time":1738416202716,"dist-tags":{"latest":"7.0.0"}}