Comparing version 0.1.6 to 1.0.0
@@ -22,4 +22,13 @@ "use strict"; | ||
registerInstance: function (instance) { | ||
if (instance.constructor) { | ||
if (dependencies.has(instance.constructor)) { | ||
throw new Error(`The instance type (${instance.constructor.name}) is already registered`); | ||
} | ||
dependencies.set(instance.constructor, instance); | ||
} | ||
return { | ||
as: (type) => { | ||
if (instance.constructor) { | ||
dependencies.delete(instance.constructor); | ||
} | ||
if (dependencies.has(type)) { | ||
@@ -26,0 +35,0 @@ throw new Error(`The instance type (${type.name}) is already registered`); |
{ | ||
"name": "cheap-di", | ||
"version": "0.1.6", | ||
"version": "1.0.0", | ||
"description": "JavaScript dependency injection like Autofac in .Net", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "jest src" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.14", | ||
"jest": "^26.4.2", | ||
"ts-jest": "^26.4.1", | ||
"tslib": "2.0.1", | ||
@@ -11,0 +14,0 @@ "typescript": "3.9.7" |
@@ -95,3 +95,2 @@ # cheap-di | ||
constructor(userRepository, logger) { | ||
super(); | ||
this.userRepository = userRepository; | ||
@@ -138,1 +137,3 @@ this.logger = logger; | ||
``` | ||
You can see more examples in `cheap-di/src/container.test.ts` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
13623
133
0
138
5