{"id":16384818,"url":"https://github.com/saber2pr/saber-ioc","last_synced_at":"2025-08-01T22:39:23.002Z","repository":{"id":108571513,"uuid":"167120618","full_name":"Saber2pr/saber-ioc","owner":"Saber2pr","description":":art: A simple Injector for ioc","archived":false,"fork":false,"pushed_at":"2019-05-20T14:02:12.000Z","size":92,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-17T14:52:05.730Z","etag":null,"topics":["aop","ioc","ioc-container","oop","reflect","typescript"],"latest_commit_sha":null,"homepage":"","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/Saber2pr.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":"2019-01-23T05:05:28.000Z","updated_at":"2020-09-04T09:54:31.000Z","dependencies_parsed_at":"2023-05-09T15:23:35.336Z","dependency_job_id":null,"html_url":"https://github.com/Saber2pr/saber-ioc","commit_stats":{"total_commits":62,"total_committers":2,"mean_commits":31.0,"dds":"0.016129032258064502","last_synced_commit":"c1cb0393637077117c003ca8a226d59d18fa6b8a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Saber2pr/saber-ioc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fsaber-ioc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fsaber-ioc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fsaber-ioc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fsaber-ioc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saber2pr","download_url":"https://codeload.github.com/Saber2pr/saber-ioc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fsaber-ioc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268308856,"owners_count":24230143,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["aop","ioc","ioc-container","oop","reflect","typescript"],"created_at":"2024-10-11T04:12:39.005Z","updated_at":"2025-08-01T22:39:22.954Z","avatar_url":"https://github.com/Saber2pr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e@saber2pr/ioc\u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@saber2pr/ioc\"\u003e\n      \u003cimg src=\"https://img.shields.io/npm/v/@saber2pr/ioc.svg?color=blue\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003ch3 align=\"center\"\u003ea simple Injector for ioc --- 快速的依赖注入IOC容器\u003c/h3\u003e\n\u003ch3 align=\"center\"\u003e兼容 Typescript，es6、es5\u003c/h3\u003e\n\n```bash\n# from npm\nnpm install @saber2pr/ioc\n\n# from github\ngit clone https://github.com/Saber2pr/saber-ioc.git\n\n```\n\n\u003e 关于反射的实现 [@saber2pr/reflect](https://github.com/Saber2pr/-saber2pr-reflect)\n\n# Feature\n\n```ts\n@Injectable()\nclass Service {\n  public getUser() {\n    return 'saber!'\n  }\n}\n\nclass Controller {\n  public constructor(@Inject('Service') private Service: Service) {}\n\n  // @InjectProp() private Service: Service\n\n  public test() {\n    console.log(this.Service.getUser())\n  }\n}\n\nconst app = Injector(Controller)\n\napp.test() // 'saber!'\n```\n\n# API\n\n1. @Injectable(id?) 注解一个类作为元数据依赖，若没有提供 id 参数，则默认注册 id 为类名\n\n   `注意：`请确保 id 是全局唯一的！\n\n2. @Inject(id) 注解一个依赖到目标类中(从注解参数)\n\n   如果依赖类型是 Interface，请务必提供 Inject 注解。\n\n3. @InjectProp(id) 注解一个依赖到目标类中(从属性注解)\n\n4. @Singleton 注册一个类为单例\n\n5. @Static 注册一个类为静态类\n\n   `你可能已经发现这和@Singleton可能是一样的，你是对的`\n\n6. Injector 执行依赖树 build，自动注入实例\n\n   `注意保证依赖在注入之前已经声明`\n\n---\n\n## start\n\n```bash\nnpm install\n```\n\n```bash\nnpm start\n\nnpm run build\n\nnpm test\n\n```\n\n---\n\n## develope and test\n\n\u003e you should write ts in /src\n\n\u003e you should make test in /src/test\n\n---\n\n# Author\n\nsaber2pr\n\n---\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaber2pr%2Fsaber-ioc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaber2pr%2Fsaber-ioc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaber2pr%2Fsaber-ioc/lists"}