@wroud/di is a lightweight dependency injection library for JavaScript, inspired by .NET's DI system. Written in TypeScript, it supports modern JavaScript features, including decorators, and provides robust dependency management capabilities.
- Modern JavaScript: Leverages ES modules, decorators, and asynchronous service loading for advanced performance optimizations.
- TypeScript: Written in TypeScript for type safety.
- Flexible DI: Supports singleton, transient, and scoped services.
- Pure ESM package
Install via npm:
npm install @wroud/di
Install via yarn
yarn add @wroud/di
For detailed usage and API reference, visit the documentation site.
import { ServiceContainerBuilder, injectable } from "@wroud/di";
@injectable()
class Logger {
log(message: string) {
console.log(message);
}
}
const builder = new ServiceContainerBuilder();
builder.addSingleton(Logger);
const provider = builder.build();
const logger = provider.getService(Logger);
logger.log("Hello world!");
All notable changes to this project will be documented in the CHANGELOG file.
This project is licensed under the MIT License. See the LICENSE file for details.