{"id":24605526,"url":"https://github.com/stevelin100132/dynamic-class","last_synced_at":"2026-04-13T12:01:56.031Z","repository":{"id":57398372,"uuid":"425416530","full_name":"SteveLin100132/dynamic-class","owner":"SteveLin100132","description":"dynamic-class 是一個用於動態類別實例化的 TypeScript 函式庫，主要目標是更高效地實現 Design Pattern（設計模式）中的簡單工廠（Simple Factory）。透過動態類別裝飾器與動態類別工廠，開發者可以使用別名或類別名稱來動態建立類別實例、降低耦合度，提升擴展性，讓新類別可以無縫整合以及簡化 Factory Pattern 的實作，無需手動維護 Mapping Table。","archived":false,"fork":false,"pushed_at":"2025-02-11T13:48:47.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T10:14:21.327Z","etag":null,"topics":["design-patterns","nodejs","simple-factory-pattern","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SteveLin100132.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2021-11-07T04:59:46.000Z","updated_at":"2025-02-11T13:49:27.000Z","dependencies_parsed_at":"2025-08-11T05:24:45.021Z","dependency_job_id":"87bad9fa-34c7-41f9-a55c-f4c36778b5ea","html_url":"https://github.com/SteveLin100132/dynamic-class","commit_stats":null,"previous_names":["stevelin100132/wistroni40-dynamic-class"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SteveLin100132/dynamic-class","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveLin100132%2Fdynamic-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveLin100132%2Fdynamic-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveLin100132%2Fdynamic-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveLin100132%2Fdynamic-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SteveLin100132","download_url":"https://codeload.github.com/SteveLin100132/dynamic-class/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveLin100132%2Fdynamic-class/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31751705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["design-patterns","nodejs","simple-factory-pattern","typescript"],"created_at":"2025-01-24T16:17:52.570Z","updated_at":"2026-04-13T12:01:55.999Z","avatar_url":"https://github.com/SteveLin100132.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dynamic-class\n\ndynamic-class 是一個用於動態類別實例化的 TypeScript 函式庫，主要目標是更高效地實現 Design Pattern（設計模式）中的簡單工廠（Simple Factory）。透過動態類別裝飾器與動態類別工廠，開發者可以使用別名或類別名稱來動態建立類別實例、降低耦合度，提升擴展性，讓新類別可以無縫整合以及簡化 Factory Pattern 的實作，無需手動維護 Mapping Table。\n\n# Install\n\n```\nnpm i dynamic-class --save\n```\n\n# Table of Contents\n\n- [Feature](#feature)\n- [Usage](#usage)\n- [Example](#example)\n\n# Feature\n\n- 提供動態實例類別\n- 可自訂類別別名，讓產生實例時，可以透過其他名稱實例對應物件\n\n# Usage\n\n### Dynamic Class Decorator\n\n使用添 `@DynamicClass()` 裝飾器，讓要動態實例的類別被記錄\n\n```typescript\nimport { DynamicClass } from 'wistroni40-dynamic-class';\n\n@DynamicClass()\nexport class CustomClass implements Custom {\n  constructor(public property: string) {}\n\n  public method() { ... }\n}\n```\n\n#### @DynamicClass()\n\n該裝飾器提供以下配置\n\n| Paramter | Type                   | Description                |\n| -------- | ---------------------- | -------------------------- |\n| alias    | string \u0026#124; string[] | 可提供單個或多個類別的別名 |\n\n```typescript\n// 單個別名\n@DynamicClass({\n  alias: 'AliasName'\n})\nclass MyClass {}\n\n// 多個別名\n@DynamicClass({\n  alias: ['AliasName1', 'AliasName2', ...]\n})\nclass MyClass {}\n```\n\n### Dynamic Class Factory\n\n使用 `DynamicClassFactory` 將指定的類別(以 String 給定類別名稱)實例\n\n```typescript\nimport { DynamicClassFactory } from 'wistroni40-dynamic-class';\n\nconst custom = DynamicClassFactory.createInstance\u003cCustom\u003e(\n  'CustomClass',\n  'custom-property',\n);\n```\n\n##### createInstance()\n\n| Paramter  | Type   | Description                                  |\n| --------- | ------ | -------------------------------------------- |\n| classNmae | string | 要實例的類別名稱                             |\n| ...args   | any[]  | 實例該類別所需的建構值參數，根據實際數量添加 |\n\n# Example\n\n- [完整範例](https://github.com/SteveLin100132/wistroni40-dynamic-class/blob/master/examples/index.ts)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevelin100132%2Fdynamic-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevelin100132%2Fdynamic-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevelin100132%2Fdynamic-class/lists"}