{"id":18084504,"url":"https://github.com/endel/injectd","last_synced_at":"2025-04-06T00:11:27.953Z","repository":{"id":42411299,"uuid":"61953050","full_name":"endel/injectd","owner":"endel","description":"Lean dependency injection for JavaScript (ES2016) and TypeScript","archived":false,"fork":false,"pushed_at":"2016-07-02T12:36:38.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T15:06:39.405Z","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/endel.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}},"created_at":"2016-06-25T17:00:37.000Z","updated_at":"2016-06-27T19:34:17.000Z","dependencies_parsed_at":"2022-09-04T06:10:59.023Z","dependency_job_id":null,"html_url":"https://github.com/endel/injectd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Finjectd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Finjectd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Finjectd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Finjectd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/endel","download_url":"https://codeload.github.com/endel/injectd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415973,"owners_count":20935387,"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-31T15:07:01.532Z","updated_at":"2025-04-06T00:11:27.930Z","avatar_url":"https://github.com/endel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"injectd 0.1 ![Build status](https://travis-ci.org/endel/injectd.svg?branch=master)\n===\n\nThis library is the leanest dependency injection implementation you can\npossibly have for JavaScript (ES2016) and TypeScript. Just **~1kb filesize\n(uncompressed)**\n\nThe API consists in three methods: `inject`, `register` and `resolve`.\n\n- `register\u003cT\u003e(idOrInstance: string | any, instance?: any): void`: Register instance with given identifier. The instance registered will be available for `inject` and `resolve` methods.\n- `inject(id: any)`: A decorator to inject a previously registered instance into target class property. ([see usage below](#usage))\n- `resolve\u003cT\u003e(id: any): T`: Get previously registered instance by given name or type. (used under the hood by `inject` method)\n\nConfiguration\n---\n\nYour compiler/transpiler need to understand the [decorator\nsyntax](https://github.com/wycats/javascript-decorators/blob/master/README.md)\nin order to be able to use `injectd`. Here's how you enable it using:\n\n- [Babel](https://babeljs.io/docs/plugins/syntax-decorators/)\n- [TypeScript](https://www.typescriptlang.org/docs/handbook/decorators.html)\n\nUsage\n---\n\n```typescript\n// application.ts\nimport { register } from \"injectd\"\n\nexport class Application {\n  constructor () {\n    register(this);\n  }\n}\n\n// screen.ts\nimport { Application } from \"./application\"\nimport { inject } from \"injectd\"\n\nexport class Screen {\n  @inject(Application)\n  app: Application;\n}\n\n// main.ts\nlet myApp = new Application();\n\n// anywhere.ts\nimport { Screen } from \"./screen\"\n\nlet screen = new Screen();\nscreen.app // your \"Application\" instance is here!\n```\n\nLicense\n---\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendel%2Finjectd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendel%2Finjectd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendel%2Finjectd/lists"}