{"id":19123411,"url":"https://github.com/dependents/node-ast-module-types","last_synced_at":"2025-04-05T22:10:29.959Z","repository":{"id":15486346,"uuid":"18220040","full_name":"dependents/node-ast-module-types","owner":"dependents","description":"AST helpers for recognizing CommonJS, AMD, and ES6 module types","archived":false,"fork":false,"pushed_at":"2025-02-01T13:31:48.000Z","size":956,"stargazers_count":12,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T21:09:08.205Z","etag":null,"topics":["amd","ast","commonjs","es6"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"MarlinFirmware/Marlin","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dependents.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-28T17:13:17.000Z","updated_at":"2025-03-27T03:53:37.000Z","dependencies_parsed_at":"2024-06-18T15:36:37.709Z","dependency_job_id":"55dc0c73-8fe4-45dd-9db8-9304c31603d4","html_url":"https://github.com/dependents/node-ast-module-types","commit_stats":{"total_commits":54,"total_committers":5,"mean_commits":10.8,"dds":0.5555555555555556,"last_synced_commit":"8a0a1ac3fd158aaa24ee7dc1a7a7dd49a731af76"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-ast-module-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-ast-module-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-ast-module-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-ast-module-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dependents","download_url":"https://codeload.github.com/dependents/node-ast-module-types/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406111,"owners_count":20933806,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amd","ast","commonjs","es6"],"created_at":"2024-11-09T05:25:34.198Z","updated_at":"2025-04-05T22:10:29.940Z","avatar_url":"https://github.com/dependents.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ast-module-types\n\n[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-ast-module-types/ci.yml?branch=main\u0026label=CI\u0026logo=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\u0026logoColor=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\nmodule 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\nand 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 all (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\n## Usage\n\n```js\nconst types = 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(types.isDefineAMD(node));\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdependents%2Fnode-ast-module-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdependents%2Fnode-ast-module-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdependents%2Fnode-ast-module-types/lists"}