@wroud/di

0.15.1 • Public • Published

@wroud/di

ESM-only package NPM version

@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.

Features

  • 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

Installation

Install via npm:

npm install @wroud/di

Install via yarn

yarn add @wroud/di

Documentation

For detailed usage and API reference, visit the documentation site.

Example

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!");

Changelog

All notable changes to this project will be documented in the CHANGELOG file.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Dependents (2)

Package Sidebar

Install

npm i @wroud/di

Weekly Downloads

12

Version

0.15.1

License

MIT

Unpacked Size

131 kB

Total Files

220

Last publish

Collaborators

  • wroud