{"id":16374445,"url":"https://github.com/azz/ioc-ts","last_synced_at":"2025-06-26T23:15:42.082Z","repository":{"id":66081964,"uuid":"80406163","full_name":"azz/ioc-ts","owner":"azz","description":"TypeScript Dependency Injection","archived":false,"fork":false,"pushed_at":"2017-01-30T11:48:51.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-14T06:35:12.401Z","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/azz.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":"2017-01-30T08:58:08.000Z","updated_at":"2019-06-29T02:55:58.000Z","dependencies_parsed_at":"2023-04-09T04:33:01.587Z","dependency_job_id":null,"html_url":"https://github.com/azz/ioc-ts","commit_stats":null,"previous_names":["derflatulator/ioc-ts"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/azz/ioc-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fioc-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fioc-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fioc-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fioc-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azz","download_url":"https://codeload.github.com/azz/ioc-ts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fioc-ts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260804325,"owners_count":23065529,"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-11T03:17:15.971Z","updated_at":"2025-06-26T23:15:42.022Z","avatar_url":"https://github.com/azz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/DerFlatulator/ioc-ts.svg)][ci-server]\n[![npm version](https://badge.fury.io/js/ioc-ts.svg)][npm-package] \n\n# ioc.ts\n\nTypeScript Dependency Injection\n\n## Features\n\n * [x] Type safe\n * [x] Tiny (614 bytes before minification or compression)\n * [x] No classes required\n * [x] Supports multiple containers\n\n## Install\n\n```bash\nnpm i -S ioc-ts\n```\n\n## API\n\nImport:\n\n```\nimport container from 'ioc-ts'\n```\n\n### `container(deps?: { [key: string]: any }): Container`\n\nCreate a container, optionally specifying dependencies.\n\nDependencies should be an object. Returns the container.\n\n```ts\nconst c = container({\n    x: 'foo',\n    y: 'bar',\n})\n```\n\n### `Container#define(deps?: { [key: string]: any }): Container`\n\nAdd additional dependencies to a container. Does not mutate underlying\ncontainer. Can be chained.\n\n```ts\nconst c = container({ x: 'foo' }).define({ y: 1 }).define({ z: true })\n// c now has x, y and z.\n```\n\n### `Container#combine(container: Container): Container`\n\nCombine the dependencies of two containers. Does not mutate underlying\ncontainer. Can be chained.\n\n```ts\nconst c1 = container({ x: 'foo' })\nconst c2 = container({ y: 1 })\nconst c = container({ z: true }).combine(c1).combine(c2)\n// c now has x, y and z.\n```\n\n### `Container#inject(fn: Function): Function`\n\nInject a function with dependencies from a container.\n\nContainer must type-match the dependencies of the target function.\n\nTarget function must specify dependencies as the first argument.\n\n```ts\nfunction iNeedDependencies(deps: { x: string }, arg1: number) {\n    console.log(deps.x, arg1)\n}\n\nconst c = container({ x: 'foo' })\nconst iHasDependencies = c.inject(iNeedDependencies)\niHasDependencies(42) // logs 'foo', 42\n```\n\n[npm-package]: https://www.npmjs.com/package/ioc-ts\n[ci-server]: https://travis-ci.org/DerFlatulator/ioc-ts\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazz%2Fioc-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazz%2Fioc-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazz%2Fioc-ts/lists"}