{"name":"ast-module-types","version":"7.0.0","description":"Collection of useful helper functions when trying to determine module type (CommonJS or AMD) properties of an AST node.","type":"module","exports":{".":"./index.js"},"scripts":{"lint":"xo","fix":"xo --fix","uvu":"uvu test -i fixtures -i utils","test":"npm run lint && npm run uvu","test:ci":"c8 npm run uvu"},"repository":{"type":"git","url":"git+https://github.com/dependents/node-ast-module-types.git"},"keywords":["esprima","module","type","define","require","factory"],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com","url":"https://mrjoelkemp.com/"},"license":"MIT","bugs":{"url":"https://github.com/dependents/node-ast-module-types/issues"},"homepage":"https://github.com/dependents/node-ast-module-types","engines":{"node":">=20.19.0 || >=22.12.0"},"devDependencies":{"c8":"^11.0.0","node-source-walk":"^8.0.0","uvu":"^0.5.6","xo":"^2.0.2"},"gitHead":"fa46d266b4f020c3e3e342876f5865fbb3f1dded","_id":"ast-module-types@7.0.0","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-WZf/zDJlZYMkn+/MSl1uwJzUnDzTpVitUCcvX2oUZzN5ccYTyiiI05249AYCOqMjvbKuwiielm7GfoQKYpH/7A==","shasum":"438871ab18efbc1704e1e5bcacbb0fec642ec61b","tarball":"http://registry-npm.ywwl.com/ast-module-types/download/ast-module-types-7.0.0.tgz","fileCount":4,"unpackedSize":11485,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDVvn3nxGJuJpUz7mUyJuqa/jTH0LEAO+OKSrLWAfUnagIhAM1OkjbrwBVgTG7IugkO03mIaRKcpttbasWrpyEeaqcx"}],"size":3582,"noattachment":false,"key":"/ast-module-types/-/ast-module-types-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/ast-module-types_7.0.0_1779199860480_0.48518556808016355"},"_hasShrinkwrap":false,"readme":"# ast-module-types\n\n[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-ast-module-types/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-ast-module-types/actions/workflows/ci.yml?query=branch%3Amain)\n[![npm version](https://img.shields.io/npm/v/ast-module-types?logo=npm&logoColor=fff)](https://www.npmjs.com/package/ast-module-types)\n[![npm downloads](https://img.shields.io/npm/dm/ast-module-types)](https://www.npmjs.com/package/ast-module-types)\n\nCollection of useful helper functions when trying to determine module type (CommonJS or AMD) properties of an AST node.\n\n**AST checks are based on the Esprima (Spidermonkey) format**\n\n```sh\nnpm install ast-module-types\n```\n\n## API\n\nEach of these takes in a single AST node argument and returns a boolean.\n\n* `isDefineAMD`: if node matches any form of an AMD `define` function call\n* `isRequire`: if node matches a `require` function call (declaring a dependency)\n* `isTopLevelRequire`: if node matches a `require` at the very top of the file.\n* `isAMDDriverScriptRequire`: if node matches an AMD driver script's require call `require([deps], function)`\n* `isExports`: if the node matches CommonJS `module.exports` or `exports` (defining a module)\n\nDetecting the various forms of defining an AMD module\n\n* `isNamedForm`: if the node is a define call of the form: `define('name', [deps], func)`\n* `isDependencyForm`: if the node is a define call of the form: `define([deps], func)`\n* `isFactoryForm`: if the node is a define call of the form: `define(func(require))`\n* `isNoDependencyForm`: if the node is a define call of the form: `define({})`\n* `isREMForm`: if the node matches the form: `define(function(require, exports, module){});`\n\nES6 Types\n\n*All types abide by the [EStree spec](https://github.com/estree/estree/blob/master/es2015.md)*\n\n* `isES6Import`: if the node is any of the es6 import forms\n* `isES6Export`: if the node is of any es6 export forms\n* `isDynamicImport`: if the node is a dynamic `import()` call\n\n## Usage\n\n### ESM\n\n```js\nimport { isDefineAMD } from 'ast-module-types';\n\n// Assume node is some node of an AST that you parsed using esprima or esprima-fb\n// ...\n\nconsole.log(isDefineAMD(node));\n```\n\n### CommonJS\n\n```js\nconst { isDefineAMD } = require('ast-module-types');\n\n// Assume node is some node of an AST that you parsed using esprima or esprima-fb\n// ...\n\nconsole.log(isDefineAMD(node));\n```\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1779199860619,"_cnpm_publish_time":1779199860619,"dist-tags":{"latest":"7.0.0"}}