{"id":16109065,"url":"https://github.com/tripolskypetr/di-kit","last_synced_at":"2026-05-07T10:39:20.447Z","repository":{"id":252791708,"uuid":"841428339","full_name":"tripolskypetr/di-kit","owner":"tripolskypetr","description":"Minimal ioc container which allow circular dependency injection","archived":false,"fork":false,"pushed_at":"2025-02-28T10:32:05.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T17:17:16.408Z","etag":null,"topics":["circular-dependencies","circular-dependency","dependency-injection","ioc","javascript","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/react-declarative/react-declarative","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/tripolskypetr.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":"2024-08-12T11:43:52.000Z","updated_at":"2025-02-28T10:32:09.000Z","dependencies_parsed_at":"2024-11-16T10:20:54.150Z","dependency_job_id":"02f6e79d-007a-4d47-b877-e43bf067c169","html_url":"https://github.com/tripolskypetr/di-kit","commit_stats":null,"previous_names":["tripolskypetr/fast-di"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripolskypetr%2Fdi-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripolskypetr%2Fdi-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripolskypetr%2Fdi-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripolskypetr%2Fdi-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tripolskypetr","download_url":"https://codeload.github.com/tripolskypetr/di-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247434598,"owners_count":20938525,"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":["circular-dependencies","circular-dependency","dependency-injection","ioc","javascript","nodejs","typescript"],"created_at":"2024-10-09T19:29:34.714Z","updated_at":"2026-05-07T10:39:20.412Z","avatar_url":"https://github.com/tripolskypetr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# di-kit\n\n\u003e Minimal ioc container which allow circular dependency injection\n\n## Installation\n\n```bash\nnpm install di-kit\n```\n\n## Code sample\n\n```tsx\nimport { inject, provide, init } from './index.mjs';\n\nconst TYPES = {\n    serviceFoo: Symbol('serviceFoo'),\n    serviceBar: Symbol('serviceBar'),\n    serviceBaz: Symbol('serviceBaz'),\n};\n\nprovide(\n    TYPES.serviceFoo, \n    () =\u003e new class {\n        bar = inject(TYPES.serviceBar);\n    }\n);\n\nprovide(\n    TYPES.serviceBar,\n    () =\u003e new class {\n        foo = inject(TYPES.serviceFoo);\n        baz = inject(TYPES.serviceBaz);\n    }\n);\n\nprovide(\n    TYPES.serviceBaz,\n    () =\u003e new class { }\n);\n\nconst ioc = {\n    serviceFoo: inject(TYPES.serviceFoo),\n    serviceBar: inject(TYPES.serviceBar),\n    serviceBaz: inject(TYPES.serviceBaz),\n};\n\ninit();\n\nconsole.log(ioc.serviceFoo.bar.name);\nconsole.log(ioc.serviceBar.foo.name);\nconsole.log(ioc.serviceBar.baz.name);\n\n```\n\n## See also\n\nIf you looking for ASP.Net Core Scoped Services alternative for NodeJS take a look on [di-scoped npm package](https://www.npmjs.com/package/di-scoped)\n\n```tsx\n\nimport { scoped } from 'di-scoped';\n\nconst TestClass = scoped(class {\n\n    constructor(private name: string) {\n    }\n\n    test() {\n        console.log(`Hello, ${this.name}`);\n    }\n});\n\n\nTestClass.runInContext(() =\u003e {\n\n    new TestClass().test(); // Hello, Peter\n\n}, \"Peter\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftripolskypetr%2Fdi-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftripolskypetr%2Fdi-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftripolskypetr%2Fdi-kit/lists"}