### Install polyuse package Source: https://github.com/exeto/polyuse/blob/main/README.md Instructions to install the polyuse library using npm. ```bash npm install polyuse ``` -------------------------------- ### Get type-safe polyuse IoC container Source: https://github.com/exeto/polyuse/blob/main/README.md Shows how to extract the type of the polyuse IoC container for improved type safety in TypeScript applications. ```typescript type Container = typeof container; ``` -------------------------------- ### Implement Inversion of Control with polyuse/ioc Source: https://github.com/exeto/polyuse/blob/main/README.md Demonstrates how to use the polyuse IoC container to manage dependencies. It shows creating singleton and transient factories for Logger, Database, and UserService classes, and then resolving them from the container. ```typescript import { createContainer, createSingletonFactory, createTransientFactory } from "polyuse/ioc"; class Logger { log(message: string) { console.log(`[${new Date().toISOString()}] ${message}`); } } const loggerFactory = createSingletonFactory(() => new Logger()); class Database { constructor(private readonly logger: Logger) {} connect() { this.logger.log("Connected to database"); } query(sql: string) { this.logger.log(`Executing query: ${sql}`); } } const databaseFactory = createSingletonFactory( () => new Database(loggerFactory.create()), ); class UserService { constructor( private readonly logger: Logger, private readonly database: Database, ) {} createUser(username: string) { this.logger.log(`Creating user: ${username}`); this.database.query(`INSERT INTO users (username) VALUES ('${username}')`); } } const userServiceFactory = createTransientFactory( () => new UserService(loggerFactory.create(), databaseFactory.create()), ); const container = createContainer({ database: databaseFactory, userService: userServiceFactory, }); // Usage container.database.connect(); const userService1 = container.resolve("userService"); const userService2 = container.resolve("userService"); userService1.createUser("alice"); userService2.createUser("bob"); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.