{"id":17743111,"url":"https://github.com/julien-r44/module-methods-extractor","last_synced_at":"2025-03-31T23:45:30.075Z","repository":{"id":86779679,"uuid":"530418996","full_name":"Julien-R44/module-methods-extractor","owner":"Julien-R44","description":"🪛 Utility module to extract public methods for a given default export.","archived":false,"fork":false,"pushed_at":"2022-08-29T23:08:09.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T15:26:02.681Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Julien-R44.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":["julien-r44"],"polar":"Julien-R44"}},"created_at":"2022-08-29T22:48:27.000Z","updated_at":"2024-05-01T15:26:02.682Z","dependencies_parsed_at":"2023-07-12T07:31:08.375Z","dependency_job_id":null,"html_url":"https://github.com/Julien-R44/module-methods-extractor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julien-R44%2Fmodule-methods-extractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julien-R44%2Fmodule-methods-extractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julien-R44%2Fmodule-methods-extractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julien-R44%2Fmodule-methods-extractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Julien-R44","download_url":"https://codeload.github.com/Julien-R44/module-methods-extractor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246558115,"owners_count":20796696,"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":[],"created_at":"2024-10-26T05:42:39.343Z","updated_at":"2025-03-31T23:45:30.054Z","avatar_url":"https://github.com/Julien-R44.png","language":"TypeScript","funding_links":["https://github.com/sponsors/julien-r44","https://polar.sh/Julien-R44"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"650\" src=\"https://user-images.githubusercontent.com/8337858/187311621-767302f4-fe05-471c-adfa-ce1b589460d1.png\" /\u003e\n  \u003cbr/\u003e\n\u003c/div\u003e\n\n# @julr/module-methods-extractor\n\n🪛 Utility module to extract public methods for a given default Typescript export. Used by the Adonis.js VSCode extension\n\n## Installation\n```bash\npnpm add @julr/module-methods-extractor\n```\n\n## Usage\n```ts\nimport { Extractor } from '@julr/module-methods-extractor'\n\nconst extractor = new Extractor()\n\nconst response = extractor.extract(`\n  export default class UserController {\n    public async index () {}\n    public async store () {}\n  }\n`)\n\nassert.deepEqual(response, {\n  kind: 'class',\n  methods: [\n    { name: 'index', lineno: 2 },\n    { name: 'store', lineno: 5 },\n  ]\n})\n```\n\n## Features supported\n- ESM `export default` is supported.\n- Handle inline class declarations like `export default UserController {}`.\n- Returns `lineno` for all methods.\n- Use `@babel/parser` instead of the Typescript Compiler API to parse the source code. This results in a much lighter dependency ( 274KB instead of 3.32MB)\n\n## Limitations\n- Only supports ESM. Commonjs `module.exports` is not supported. ( Maybe later ? )\n- The export reference must be located as a top level property. For example:\n    ```ts\n    const someObject = {\n      prop: class UserController {}\n    }\n\n    export default someObject.prop\n    ```\n\n    The above expression is not something we advocate in the Adonis.js eco-system and also it is not a great pattern to use either.\n\n## Acknowledgements\n\n- [Harminder Virk](https://github.com/thetutlage) for developping the [initial version of this module](https://github.com/poppinss/module-methods-extractor).\n\n## License\n\n[MIT](./LICENSE.md) License © 2022 [Julien Ripouteau](https://github.com/Julien-R44)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulien-r44%2Fmodule-methods-extractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulien-r44%2Fmodule-methods-extractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulien-r44%2Fmodule-methods-extractor/lists"}