0.1.4 • Published 1 year ago

@guarapi/di-container v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@guarapi/di-container

CI license Coverage Status npm version

This is a lightweight and flexible dependency injection (DI) container library for JavaScript and TypeScript applications. It provides a simple yet powerful way to manage and resolve dependencies within your projects.

Installation

You can install the package via npm or yarn:

pnpm add @guarapi/di-container
# or
npm install @guarapi/di-container
# or
yarn add @guarapi/di-container

Usage

Creating Dependency Keys

First, you need to create symbols to act as keys for your dependencies using the createDependencyKey function:

import { createDependencyKey } from '@guarapi/di-container';

const myDependencyKey = createDependencyKey<string>('myDependency');

Setting Dependencies

Then, you can set dependencies in the container using the set method:

import Container from '@guarapi/di-container';

const container = new Container()
  .set(myDependencyKey, () => 'Dependency value');

Getting Dependencies

Finally, you can retrieve dependencies from the container using the get method:

const dependencyValue = container.get(myDependencyKey);
console.log(dependencyValue); // Output: Dependency value

Contributing

Contributions are welcome! Please feel free to submit any issues or pull requests.

License

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

0.1.4

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago