{"name":"module-definition","version":"7.0.0","description":"Determines if a file is using a CommonJS or AMD module definition","type":"module","exports":{".":"./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":">=20.19.0 || >=22.12.0"},"dependencies":{"ast-module-types":"^7.0.0","node-source-walk":"^8.0.0"},"devDependencies":{"c8":"^11.0.0","globals":"^17.6.0","memfs":"^4.57.2","mocha":"^11.7.5","unionfs":"^4.6.0","xo":"^2.0.2"},"gitHead":"7eec88738f323a5f34cc1e60566624af65132a7e","_id":"module-definition@7.0.0","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-ctl9cJHEHUqP8IehBhEq9NuykuFVJAhxeLR4BeObsrcwrZMTu2ax3F22Ii5bad1T41LwKOug/9FAzO9wmfAZ1Q==","shasum":"ca1b9b46c7d4327a282a360aa0d1962a01868010","tarball":"http://registry-npm.ywwl.com/module-definition/download/module-definition-7.0.0.tgz","fileCount":5,"unpackedSize":7309,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDea2OFyPpEVwvTMhs1c7wHBsBCLdkzYSoTfK+A+ZtvyAIgGTFDHbfK8FGHsfTvUjZEbH1rnG3ycUqumo+9riVAMLA="}],"size":2958,"noattachment":false,"key":"/module-definition/-/module-definition-7.0.0.tgz"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"directories":{},"maintainers":[{"name":"pahen","email":"patrik.henningsson@gmail.com"},{"name":"mrjoelkemp","email":"mrjoelkemp@gmail.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/module-definition_7.0.0_1779200769201_0.6089808606155163"},"_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 by walking through the AST.\n\n```sh\nnpm install module-definition\n```\n\n## Usage\n\n### ESM\n\n```js\nimport getModuleType from '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\n### CJS\n\n```js\nconst { default: 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":1779200769402,"_cnpm_publish_time":1779200769402,"dist-tags":{"latest":"7.0.0"}}