{"id":13527508,"url":"https://github.com/vovaspace/brandi","last_synced_at":"2025-04-01T09:31:40.032Z","repository":{"id":38369751,"uuid":"339143072","full_name":"vovaspace/brandi","owner":"vovaspace","description":"The dependency injection container powered by TypeScript.","archived":false,"fork":false,"pushed_at":"2023-07-31T11:34:47.000Z","size":1251,"stargazers_count":204,"open_issues_count":14,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T11:34:32.951Z","etag":null,"topics":["container","dependency-injection","dependency-injection-container","dependency-inversion","di-container","inversion-of-control","inversion-of-control-container","ioc-container","typescript"],"latest_commit_sha":null,"homepage":"https://brandi.js.org","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vovaspace.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}},"created_at":"2021-02-15T16:47:53.000Z","updated_at":"2025-03-26T06:10:52.000Z","dependencies_parsed_at":"2024-01-13T22:53:32.912Z","dependency_job_id":"28205616-60f3-4632-a4b9-2e0d9e601279","html_url":"https://github.com/vovaspace/brandi","commit_stats":{"total_commits":154,"total_committers":4,"mean_commits":38.5,"dds":"0.051948051948051965","last_synced_commit":"b56749ac24a4e71a21502695a3f98a299616fa1b"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vovaspace%2Fbrandi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vovaspace%2Fbrandi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vovaspace%2Fbrandi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vovaspace%2Fbrandi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vovaspace","download_url":"https://codeload.github.com/vovaspace/brandi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246616179,"owners_count":20806071,"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":["container","dependency-injection","dependency-injection-container","dependency-inversion","di-container","inversion-of-control","inversion-of-control-container","ioc-container","typescript"],"created_at":"2024-08-01T06:01:49.796Z","updated_at":"2025-04-01T09:31:39.041Z","avatar_url":"https://github.com/vovaspace.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# 🥃 Brandi\n\n**Brandi** is a dependency injection container powered by TypeScript.\n\n- **Framework agnostic.** Can work with any UI or server framework.\n- **Lightweight and Effective.** It is tiny and designed for maximum performance.\n- **Strongly typed.** TypeScript support out of box.\n- **Decorators free.** Does not require additional parameters in `tsconfig.json` and `Reflect` polyfill.\n\n## Packages\n\nThe Brandi packages are available for use with a module bundler or in a Node application.\n\nThe Brandi source code is written in TypeScript but we precompile both CommonJS and ESModule builds to **ES2018**.\n\nAdditionally, we provide builds precompiled to **ESNext** by `esnext`, `esnext:main` and `esnext:module` fields.\n\n**TypeScript** type definitions are **included** in the library and do not need to be installed additionally.\n\n### Brandi\n\nThe core library.\n\n[![License](https://img.shields.io/npm/l/brandi.svg)](https://github.com/vovaspace/brandi/blob/main/packages/brandi/LICENSE)\n[![NPM Version](https://img.shields.io/npm/v/brandi.svg)](https://www.npmjs.com/package/brandi)\n[![Minzipped Size](https://img.shields.io/bundlephobia/minzip/brandi.svg)](https://bundlephobia.com/result?p=brandi)\n\n```bash\n# NPM\nnpm install brandi\n```\n\n```bash\n# Yarn\nyarn add brandi\n```\n\n### Brandi-React\n\nThe React bindings layer. It lets your React components get dependencies from Brandi containers.\n\n[![License](https://img.shields.io/npm/l/brandi-react.svg)](https://github.com/vovaspace/brandi/blob/main/packages/brandi-react/LICENSE)\n[![NPM Version](https://img.shields.io/npm/v/brandi-react.svg)](https://www.npmjs.com/package/brandi-react)\n[![Minzipped Size](https://img.shields.io/bundlephobia/minzip/brandi-react.svg)](https://bundlephobia.com/result?p=brandi-react)\n\nBrandi-React requires **React 16.8 or later**.\nYou'll also need to [install](https://brandi.js.org/getting-started/installation) Brandi.\n\n```bash\n# NPM\nnpm install brandi-react\n```\n\n```bash\n# Yarn\nyarn add brandi-react\n```\n\n## No Dependencies\n\nBrandi has no dependencies, but requires the following globals in order to work:\n\n- `Symbol`\n- `WeakMap`\n\n## Production\n\nBy default, Brandi will be in development mode. The development mode includes warnings about common mistakes\nand `capture()/restore()` `Container` methods.\n\nDon't forget to set `process.env.NODE_ENV` to `production` when deploying your application.\n\n## Documentation\n\nYou can find the Brandi documentation on the [website](https://brandi.js.org).\n\nThe documentation is divided into several sections:\n\n- Getting Started\n  - [Overview](https://brandi.js.org/getting-started)\n  - [Installation](https://brandi.js.org/getting-started/installation)\n- Reference\n  - [API Reference](https://brandi.js.org/reference)\n  - [Pointers and Registrators](https://brandi.js.org/reference/pointers-and-registrators)\n  - [Container](https://brandi.js.org/reference/container)\n  - [Binding Types](https://brandi.js.org/reference/binding-types)\n  - [Binding Scopes](https://brandi.js.org/reference/binding-scopes)\n  - [Optional Dependencies](https://brandi.js.org/reference/optional-dependencies)\n  - [Dependency Modules](https://brandi.js.org/reference/dependency-modules)\n  - [Hierarchical Containers](https://brandi.js.org/reference/hierarchical-containers)\n  - [Conditional Bindings](https://brandi.js.org/reference/conditional-bindings)\n- Brandi-React\n  - [Overview](https://brandi.js.org/brandi-react)\n  - [`ContainerProvider`](https://brandi.js.org/brandi-react/container-provider)\n  - [`useInjection`](https://brandi.js.org/brandi-react/use-injection)\n  - [`createInjectionHooks`](https://brandi.js.org/brandi-react/create-injection-hooks)\n  - [`tagged`](https://brandi.js.org/brandi-react/tagged)\n- Examples\n  - [Basic Examples](https://brandi.js.org/examples)\n\n## Examples\n\nHere are just basic examples.\n\n\u003c!-- More examples can be found in the documentation in the [Examples](https://brandi.js.org/examples) section. --\u003e\n\n### Getting Instance\n\n**Binding types** and **scopes** are detailed in [Binding Types](https://brandi.js.org/reference/binding-types)\nand [Binding Scopes](https://brandi.js.org/reference/binding-scopes) sections of the documentation.\n\n\u003c!-- prettier-ignore-start --\u003e\n```typescript\nimport { Container, token } from 'brandi';\n\nclass ApiService {}\n\nconst TOKENS = {\n  /*          ↓ Creates a typed token. */\n  apiService: token\u003cApiService\u003e('apiService'),\n};\n\nconst container = new Container();\n\ncontainer\n  .bind(TOKENS.apiService)\n  .toInstance(ApiService) /* ← Binds the token to an instance */\n  .inTransientScope(); /*    ← in transient scope. */\n\n/*                           ↓ Gets the instance from the container. */\nconst apiService = container.get(TOKENS.apiService);\n\nexpect(apiService).toBeInstanceOf(ApiService);\n```\n\u003c!-- prettier-ignore-end --\u003e\n\n### Snapshoting\n\n\u003c!-- prettier-ignore-start --\u003e\n```typescript\nimport { Container, token } from 'brandi';\n\nconst TOKENS = {\n  apiKey: token\u003cstring\u003e('API Key'),\n};\n\nconst container = new Container();\n\ncontainer\n  .bind(TOKENS.apiKey)\n  .toConstant('#key9428'); /* ← Binds the token to some string. */\n\n/*        ↓ Captures (snapshots) the current container state. */\ncontainer.capture();\n\ncontainer\n  .bind(TOKENS.apiKey)\n  .toConstant('#testKey'); /* ← Binds the same token to another value. */\n                           /*   For example, this can be used in testing. */\n\nconst testKey = container.get(TOKENS.apiKey);\n\n/*        ↓ Restores the captured container state. */\ncontainer.restore();\n\nconst originalKey = container.get(TOKENS.apiKey);\n\nexpect(testKey).toBe('#testKey');\nexpect(originalKey).toBe('#key9428');\n```\n\u003c!-- prettier-ignore-end --\u003e\n\nOther `Container` methods are detailed\nin [Container](https://brandi.js.org/reference/container) section of the documentation.\n\n### Hierarchical Containers\n\nHierarchical containers are detailed\nin [Hierarchical Containers](https://brandi.js.org/reference/hierarchical-containers) section of the documentation.\n\n```typescript\nimport { Container, token } from 'brandi';\n\nclass ApiService {}\n\nconst TOKENS = {\n  apiService: token\u003cApiService\u003e('apiService'),\n};\n\nconst parentContainer = new Container();\n\nparentContainer\n  .bind(TOKENS.apiService)\n  .toInstance(ApiService)\n  .inTransientScope();\n\n/*                     ↓ Creates a container with the parent. */\nconst childContainer = new Container().extend(parentContainer);\n\n/**                ↓ That container can't satisfy the getting request,\n *                   it passes it along to its parent container.\n *                   The intsance will be gotten from the parent container.\n */\nconst apiService = childContainer.get(TOKENS.apiService);\n\nexpect(apiService).toBeInstanceOf(ApiService);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvovaspace%2Fbrandi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvovaspace%2Fbrandi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvovaspace%2Fbrandi/lists"}