UNPKG

di-singleton

Version:

Wraps a class constructor to ensure only one instance is created, using lazy initialization and optionally calling an init method if present, while maintaining type safety via TypeScript generics.

7 lines (5 loc) 217 B
declare const singleton: <ClassType extends new (...args: any[]) => any>(ClassCtor: ClassType) => ClassType & { clear(): void; clear(...args: ConstructorParameters<ClassType>): void; }; export { singleton };