{"id":21835677,"url":"https://github.com/bryanjhv/js-class-info","last_synced_at":"2025-03-21T14:24:02.926Z","repository":{"id":57199463,"uuid":"74850866","full_name":"bryanjhv/js-class-info","owner":"bryanjhv","description":"Get information about your ES5/ES6 class.","archived":false,"fork":false,"pushed_at":"2016-11-27T05:07:24.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T08:43:49.431Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/bryanjhv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-26T21:12:53.000Z","updated_at":"2016-11-26T21:13:12.000Z","dependencies_parsed_at":"2022-09-16T15:00:52.217Z","dependency_job_id":null,"html_url":"https://github.com/bryanjhv/js-class-info","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanjhv%2Fjs-class-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanjhv%2Fjs-class-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanjhv%2Fjs-class-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanjhv%2Fjs-class-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bryanjhv","download_url":"https://codeload.github.com/bryanjhv/js-class-info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244812089,"owners_count":20514401,"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-11-27T20:23:30.490Z","updated_at":"2025-03-21T14:24:02.901Z","avatar_url":"https://github.com/bryanjhv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Class Info\n\nGet information about your ES5/ES6 class.\n\n\n## Usage\n\n`require()` the module and pass your class constructor, like so:\n\n```js\nlet classInfo = require('class-info');\n\nclass Shape {\n  constructor(x, y) {\n    this.x = x;\n    this.y = y;\n  }\n  \n  getPosition() {\n    return {x: this.x, y: this.y};\n  }\n  \n  static place({x, y}) {\n    return new Shape(x, y);\n  }\n}\n\nlet shapeInfo = classInfo(Shape);\nconsole.log(shapeInfo); // -\u003e { staticMethods: ['place'],\n                        //      instanceMethods: ['getPosition'],\n                        //      staticProperties: [],\n                        //      instanceProperties: [],\n                        //      parentClass: null }\n\nclass Circle extends Shape {\n  constructor(x, y, r) {\n    super(x, y);\n    this.r = r;\n  }\n  \n  getArea() {\n    return Math.PI * this.r * this.r;\n  }\n}\n\nCircle.NONE = new Circle(0, 0, 0);\n\nlet circleInfo = classInfo(Circle);\nconsole.log(circleInfo); // -\u003e { staticMethods: [],\n                         //      instanceMethods: ['getArea'],\n                         //      staticProperties: ['NONE'],\n                         //      instanceProperties: [],\n                         //      parentClass: Shape }\n\nconsole.log(circleInfo.parentClass.name); // -\u003e 'Shape'\n```\n\n### Information returned\n\n- `staticMethods` contains all the static method names, defined via ES6 `static`\n  keyword inside a class, or in both ES5/ES6 with `[class].[method]` syntax.\n- `instanceMethods` contains all the instance method names, defined via ES6\n  `[method](...) { ... }` or via ES5`[class].prototype.[method] = ...`.\n- `staticProperties` lists all the properties names assigned with the syntax for\n  both ES5/ES6 `[class].[property]`.\n- `instanceProperties` **is not implemented**, but it'll be, I promise.\n- `parentClass` contains the **raw** parent class (i.e. the constructor) which\n  this class was derived from. If no parents were found, it's `null`.\n\n### Warnings\n\n- I'm not sure if `parentClass` is realiable, so use it with caution, only in\n  extreme cases where you need it.\n\n\n## License\n\nThis project is released under the [MIT license](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryanjhv%2Fjs-class-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbryanjhv%2Fjs-class-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryanjhv%2Fjs-class-info/lists"}