{"name":"ast-module-types","version":"6.0.2","keywords":["esprima","module","type","define","require","factory"],"author":{"url":"https://mrjoelkemp.com/","name":"Joel Kemp","email":"joel@mrjoelkemp.com"},"license":"MIT","_id":"ast-module-types@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/node-ast-module-types","bugs":{"url":"https://github.com/dependents/node-ast-module-types/issues"},"xo":{"rules":{"curly":["error","multi-line"],"comma-dangle":["error","never"],"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-node-protocol":"off","unicorn/prevent-abbreviations":"off","unicorn/prefer-top-level-await":"off","unicorn/no-anonymous-default-export":"off"},"space":true,"ignores":["test/fixtures/*"]},"dist":{"shasum":"b18a07de36bce4dfb88edf051c8d6808d4fe3dd6","tarball":"http://registry-npm.ywwl.com/ast-module-types/download/ast-module-types-6.0.2.tgz","fileCount":4,"integrity":"sha512-6KuK/7nZ/2Qh7sGuVEiwxjCxzTY2Pdb5mTo5z1e6/J8BA0tvjR7G8vQJKrQMTqwmnA3UPEyKIFX4YUS1DO1Hvw==","signatures":[{"sig":"MEQCIED+nGbhqeFTOcxF7XQ67HWwbb6zFS3DdcZEDiknTkt9AiAXVgRH/oIPeMbT5/LBW4wCxJVQ2euODFVgkl7OHBm4VA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12039,"size":3746,"noattachment":false,"key":"/ast-module-types/-/ast-module-types-6.0.2.tgz"},"main":"index.js","engines":{"node":">=18"},"gitHead":"485ff549ccdc3d33ac0ce270c6e13e89632b7179","scripts":{"fix":"xo --fix","uvu":"uvu test -i fixtures -i utils","lint":"xo","test":"npm run lint && npm run uvu","test:ci":"c8 npm run uvu"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"repository":{"url":"git+https://github.com/dependents/node-ast-module-types.git","type":"git"},"_npmVersion":"11.12.1","description":"Collection of useful helper functions when trying to determine module type (CommonJS or AMD) properties of an AST node.","directories":{},"_nodeVersion":"24.15.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","xo":"^0.60.0","uvu":"^0.5.6","node-source-walk":"^7.0.2"},"_npmOperationalInternal":{"tmp":"tmp/ast-module-types_6.0.2_1778331896674_0.07273623876645785","host":"s3://npm-registry-packages-npm-production"},"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":1778331896808,"_cnpm_publish_time":1778331896808,"dist-tags":{"latest":"7.0.0"}}