{"name":"module-definition","version":"6.0.2","keywords":[],"author":{"url":"https://mrjoelkemp.com/","name":"Joel Kemp","email":"joel@mrjoelkemp.com"},"license":"MIT","_id":"module-definition@6.0.2","maintainers":[{"name":"pahen","email":"patrik.henningsson@gmail.com"},{"name":"mrjoelkemp","email":"mrjoelkemp@gmail.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"homepage":"https://github.com/dependents/module-definition","bugs":{"url":"https://github.com/dependents/module-definition/issues"},"xo":{"rules":{"curly":["error","multi-line"],"comma-dangle":["error","never"],"prefer-template":"error","arrow-body-style":"off","operator-linebreak":["error","after"],"capitalized-comments":"off","object-curly-spacing":["error","always"],"unicorn/prefer-module":"off","space-before-function-paren":["error","never"],"unicorn/prefer-string-slice":"off","unicorn/prefer-node-protocol":"off","unicorn/prevent-abbreviations":"off","unicorn/prefer-top-level-await":"off","unicorn/no-anonymous-default-export":"off"},"space":true,"ignores":["test/fixtures/*"]},"bin":{"module-definition":"bin/cli.js"},"dist":{"shasum":"d72a3613dbf6fe7247ebef64f11fddc2cd18b83b","tarball":"http://registry-npm.ywwl.com/module-definition/download/module-definition-6.0.2.tgz","fileCount":5,"integrity":"sha512-SvAU3lB0+Yjbq55yHY3wkRZBOh+fhU1SnIF3IFbTewv6mtAh7yUT8ACHAJ2mGIJ7tCes2QuCL/cl6m0JSZ/ArA==","signatures":[{"sig":"MEUCIQCTrCI4oa/du14wBhnZ/BIWKkohQ5j3944kv1FF3HSvuQIgBokYdGZJhnaybX4/csnXwVE+6NfeoN8/h1ALpC9vVjw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7718,"size":3149,"noattachment":false,"key":"/module-definition/-/module-definition-6.0.2.tgz"},"main":"index.js","engines":{"node":">=18"},"gitHead":"5537cb8c941fbda9218aab7fbd2cffd81a71aa79","scripts":{"fix":"xo --fix","lint":"xo","test":"npm run lint && npm run mocha","mocha":"mocha","test:ci":"c8 npm run mocha"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"repository":{"url":"git+https://github.com/dependents/module-definition.git","type":"git"},"_npmVersion":"11.12.1","description":"Determines if a file is using a CommonJS or AMD module definition","directories":{},"_nodeVersion":"24.15.0","dependencies":{"ast-module-types":"^6.0.1","node-source-walk":"^7.0.1"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","xo":"^0.60.0","memfs":"^4.57.1","mocha":"^11.7.5","unionfs":"^4.6.0"},"_npmOperationalInternal":{"tmp":"tmp/module-definition_6.0.2_1776660800782_0.5481030821634825","host":"s3://npm-registry-packages-npm-production"},"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":1776660800919,"_cnpm_publish_time":1776660800919,"dist-tags":{"latest":"7.0.0"}}