ioc-service-container
Version:
Lightweight ioc service container
31 lines (30 loc) • 1.03 kB
TypeScript
declare const _default: {
/**
* Register a service in the container
* @param id {string} to identify the service in the container, it can be mapped to a property name via the inject decorator
* @param provider factory, constructable or entity which is stored in the container
*/
set<T>(id: string, provider: NoUndefined<T>): void;
/**
* Overrides a service in the container. If the service does not exist, it will be registered.
* @param id {string}
* @param provider
*/
override<T_1>(id: string, provider: NoUndefined<T_1>): void;
/**
* Get a service from the container. If the service is not instantiated, it will be instantiated.
* @param id {string}
*/
get<T_2>(id: string): T_2;
/**
* Check if the service is set in the container
* @param id {string}
*/
isSet(id: string): boolean;
/**
* Reset the container
*/
reset(): void;
};
export default _default;
type NoUndefined<T> = T extends undefined ? never : T;