Socket
Socket
Sign inDemoInstall

@owja/ioc

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-beta.4 to 1.0.0

24

package.json
{
"name": "@owja/ioc",
"version": "1.0.0-beta.4",
"version": "1.0.0",
"description": "dependency injection for javascript",

@@ -20,4 +20,4 @@ "main": "dist/ioc.js",

"test": "jest",
"lint": "eslint --ext .ts,.js ./",
"lint:fix": "eslint --ext .ts,.js ./ --fix",
"lint": "eslint --ext .ts ./src",
"lint:fix": "eslint --ext .ts ./src --fix",
"prettier": "prettier src/**/*.ts --check",

@@ -38,13 +38,13 @@ "prettier:fix": "prettier src/**/*.ts --write",

"devDependencies": {
"@types/jest": "^24.0.13",
"@typescript-eslint/eslint-plugin": "^1.10.2",
"@typescript-eslint/parser": "^1.10.2",
"eslint": "^5.16.0",
"eslint-plugin-jest": "^22.6.4",
"jest": "^24.8.0",
"@types/jest": "^24.0.19",
"@typescript-eslint/eslint-plugin": "^2.4.0",
"@typescript-eslint/parser": "^2.4.0",
"eslint": "^6.5.1",
"eslint-plugin-jest": "^22.19.0",
"jest": "^24.9.0",
"microbundle": "^0.11.0",
"prettier": "^1.18.2",
"ts-jest": "^24.0.2",
"ts-node": "^8.2.0",
"typescript": "^3.5.1"
"ts-jest": "^24.1.0",
"ts-node": "^8.4.1",
"typescript": "^3.6.4"
},

@@ -51,0 +51,0 @@ "mangle": {

@@ -10,5 +10,2 @@ ![OWJA! IoC](resources/owja-ioc-logo.png)

This library implements dependency injection for javascript.
It is currently work in progress and in unstable beta phase
but the API should not change anymore before 1.0.0 stable release
will arrive.

@@ -22,3 +19,3 @@ ## Features

* Supports binding in **singleton scope**
* **Cached** - Resolves only once in each dependency requesting class by default
* **Cached** - Resolves only once in each dependent class by default
* **Cache can switched off** directly at the inject decorator

@@ -35,4 +32,4 @@ * Made with **unit testing** in mind

The container is the place where all dependencies get bound to. We can have
multiple containers in our project in parallel.
The container is the place where all dependencies get bound to. It is possible to have
multiple container in our project in parallel.

@@ -84,3 +81,3 @@ ```ts

```ts
container.bind<ServiceInterface>(symbol).toValue(new Service());
container.bind<ServiceInterface>(symbol).toValue(new Service()); // Bad, should be avoid
container.bind<string>(symbol).toValue("just a string");

@@ -110,4 +107,5 @@ container.bind<() => string>(symbol).toValue(() => "i am a function");

Getting dependencies without `inject` decorators are only meant for **unit tests**. This is also
the internal way the `inject` decorator gets the dependency it has to resolve.
Getting dependencies without `@inject` decorators trough `container.get()` is only meant for **unit tests**.
This is also the internal way how the `@inject` decorator and the functions `wire()` and `resolve()` are getting the
dependency.

@@ -118,2 +116,9 @@ ```ts

To get a dependency without `@inject` decorator in production code use `wire()` or `resolve()`. Using `container.get()`
directly to getting dependencies can result in infinite loops with circular dependencies when called inside of
constructors. In addition `container.get()` does not respect the cache.
> **Important Note:** You should avoid accessing the dependencies from any constructor. With circular dependencies
> this can result in a infinite loop.
### Snapshot & Restore

@@ -198,3 +203,3 @@

class Example {
readonly service = resolve<Interface>(symbol)
private readonly service = resolve<Interface>(symbol);

@@ -209,3 +214,3 @@ method() {

function Example() {
const service = resolve<Interface>(symbol)
const service = resolve<Interface>(symbol);
service().doSomething();

@@ -219,3 +224,3 @@ }

> using `get()` inside of classes because we then loose the lazy dependency
> resolving/injection behavior.
> resolving/injection behavior and caching.

@@ -349,3 +354,3 @@ ## The `symbol`

test("can do something", () => {
container.rebind<MyServiceMock>(TYPE.MySerice).to(MyServiceMock);
container.rebind<MyServiceMock>(TYPE.MySerice).toValue(new MyServiceMock());
const mock = container.get<MyServiceMock>(TYPE.MySerice);

@@ -357,4 +362,4 @@ });

We are working on the first stable release. Current state of development can be seen in our
[Github Project](https://github.com/owja/ioc/projects/1) for the first release.
Current state of development can be seen in our
[Github Projects](https://github.com/owja/ioc/projects).

@@ -361,0 +366,0 @@ ## Inspiration

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc