ts-ioc-container
Version:
Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.
27 lines (26 loc) • 1.19 kB
TypeScript
import { type ArgsFn, type DecorateFn, type GetCacheKey, type IProvider, type ProviderOptions, type ResolveDependency, type ScopeAccessOptions, type ScopeAccessRule } from './IProvider';
import type { DependencyKey, IContainer } from '../container/IContainer';
import { type constructor } from '../utils/basic';
export declare class Provider<T = any> implements IProvider<T> {
private readonly resolveDependency;
static fromClass<T>(Target: constructor<T>): IProvider<T>;
static fromValue<T>(value: T): IProvider<T>;
static fromKey<T>(key: DependencyKey): Provider<T>;
private readonly argsFnList;
private readonly accessRules;
private readonly mappers;
private isLazy;
private cache;
private getKey;
private isDisposed;
constructor(resolveDependency: ResolveDependency<T>);
resolve(scope: IContainer, options: ProviderOptions): T;
private resolveDep;
map(...mappers: DecorateFn<T>[]): this;
addAccessRule(...rules: ScopeAccessRule[]): this;
lazy(): this;
addArgsFn(...fns: ArgsFn[]): this;
hasAccess(options: ScopeAccessOptions): boolean;
singleton(getCacheKey?: GetCacheKey): this;
dispose(): void;
}