honestjs
Version:
HonestJS - a modern web framework built on top of Hono
25 lines (24 loc) • 959 B
TypeScript
import type { DiContainer } from '../interfaces';
import type { Constructor } from '../types';
/**
* Dependency Injection container that manages class instances and their dependencies
*/
export declare class Container implements DiContainer {
/**
* Map of class constructors to their instances
*/
private instances;
/**
* Resolves a class instance, creating it if necessary and injecting its dependencies
* @param target - The class constructor to resolve
* @param resolving - A set of classes currently being resolved, for circular dependency detection
* @returns An instance of the target class
*/
resolve<T>(target: Constructor<T>, resolving?: Set<Constructor>): T;
/**
* Registers a pre-created instance for a class
* @param target - The class constructor to register
* @param instance - The instance to register
*/
register<T>(target: Constructor<T>, instance: T): void;
}