1- # ioc-n-di
1+ # @ cryxto/ ioc-n-di
22
33A lightweight, type-safe TypeScript IoC (Inversion of Control) container and dependency injection library with decorator support.
44
@@ -18,13 +18,13 @@ A lightweight, type-safe TypeScript IoC (Inversion of Control) container and dep
1818## Installation
1919
2020``` bash
21- npm install ioc-n-di reflect-metadata
21+ npm install @cryxto/ ioc-n-di reflect-metadata
2222```
2323
2424or with bun:
2525
2626``` bash
27- bun add ioc-n-di reflect-metadata
27+ bun add @cryxto/ ioc-n-di reflect-metadata
2828```
2929
3030** Important** : This library requires ` reflect-metadata ` as a peer dependency.
@@ -46,7 +46,7 @@ Add these settings to your `tsconfig.json`:
4646
4747``` typescript
4848import ' reflect-metadata' ;
49- import { Container , Injectable } from ' ioc-n-di' ;
49+ import { Container , Injectable } from ' @cryxto/ ioc-n-di' ;
5050
5151@Injectable ()
5252class Logger {
@@ -81,7 +81,7 @@ const user = userService.getUser(1);
8181
8282``` typescript
8383import ' reflect-metadata' ;
84- import { Container , Injectable } from ' ioc-n-di' ;
84+ import { Container , Injectable } from ' @cryxto/ ioc-n-di' ;
8585
8686@Injectable ()
8787class Database {
@@ -113,7 +113,7 @@ repo.findAll();
113113Use tokens when you need to inject interfaces or specific implementations:
114114
115115``` typescript
116- import { Container , Injectable , Inject } from ' ioc-n-di' ;
116+ import { Container , Injectable , Inject } from ' @cryxto/ ioc-n-di' ;
117117
118118// Define tokens
119119const DATABASE_URL = Symbol (' DATABASE_URL' );
@@ -156,7 +156,7 @@ service.connect();
156156Create instances using factory functions:
157157
158158``` typescript
159- import { Container } from ' ioc-n-di' ;
159+ import { Container } from ' @cryxto/ ioc-n-di' ;
160160
161161const CONFIG_TOKEN = Symbol (' CONFIG' );
162162const HTTP_CLIENT = Symbol (' HTTP_CLIENT' );
@@ -185,7 +185,7 @@ const httpClient = await container.resolve(HTTP_CLIENT);
185185Handle circular dependencies using lazy references:
186186
187187``` typescript
188- import { Container , Injectable , Lazy , LazyRef } from ' ioc-n-di' ;
188+ import { Container , Injectable , Lazy , LazyRef } from ' @cryxto/ ioc-n-di' ;
189189
190190@Injectable ()
191191class ServiceA {
@@ -223,7 +223,7 @@ serviceA.doSomething();
223223Execute initialization logic after instantiation:
224224
225225``` typescript
226- import { Container } from ' ioc-n-di' ;
226+ import { Container } from ' @cryxto/ ioc-n-di' ;
227227
228228class DatabaseConnection {
229229 isConnected = false ;
@@ -252,7 +252,7 @@ console.log(db.isConnected); // true
252252The easiest way to initialize your application - register and resolve all providers at once:
253253
254254``` typescript
255- import { Container , Injectable } from ' ioc-n-di' ;
255+ import { Container , Injectable } from ' @cryxto/ ioc-n-di' ;
256256
257257@Injectable ()
258258class ConfigService {
@@ -302,7 +302,7 @@ await container.bootstrap({
302302Store custom metadata with your services (useful for plugins, documentation, etc.):
303303
304304``` typescript
305- import { Injectable , getInjectableMetadata } from ' ioc-n-di' ;
305+ import { Injectable , getInjectableMetadata } from ' @cryxto/ ioc-n-di' ;
306306
307307@Injectable ({
308308 metadata: {
@@ -324,7 +324,7 @@ console.log(metadata?.scope); // 'singleton'
324324Manually resolve all registered providers in optimal order:
325325
326326``` typescript
327- import { Container , Injectable } from ' ioc-n-di' ;
327+ import { Container , Injectable } from ' @cryxto/ ioc-n-di' ;
328328
329329@Injectable ()
330330class ConfigService {}
@@ -465,7 +465,7 @@ container.register({
465465### Testing
466466
467467``` typescript
468- import { Container } from ' ioc-n-di' ;
468+ import { Container } from ' @cryxto/ ioc-n-di' ;
469469
470470describe (' MyService' , () => {
471471 let container: Container ;
0 commit comments