Comparing version 4.1.0 to 4.1.1
@@ -23,7 +23,15 @@ "use strict"; | ||
let asType = undefined; | ||
const asAnotherType = (type) => { | ||
this.dependencies.delete(implementationType); | ||
this.dependencies.set(type, implementationType); | ||
asType = type; | ||
const enrichCallback = this.enrichCallbacks.get(implementationType); | ||
if (enrichCallback) { | ||
this.enrichCallbacks.delete(implementationType); | ||
this.enrichCallbacks.set(type, enrichCallback); | ||
} | ||
}; | ||
const registeredImplementation = { | ||
as: (type) => { | ||
this.dependencies.delete(implementationType); | ||
this.dependencies.set(type, implementationType); | ||
asType = type; | ||
asAnotherType(type); | ||
return registeredImplementation; | ||
@@ -33,5 +41,3 @@ }, | ||
if (type) { | ||
this.dependencies.delete(implementationType); | ||
this.dependencies.set(type, implementationType); | ||
asType = type; | ||
asAnotherType(type); | ||
} | ||
@@ -96,2 +102,3 @@ if (!(0, isSingleton_js_1.isSingleton)(implementationType)) { | ||
try { | ||
// return this.internalResolve(type, trace, ...args); | ||
const resolvedInstance = this.internalResolve(type, trace, ...args); | ||
@@ -131,2 +138,3 @@ const enrichCallback = this.enrichCallbacks.get(type); | ||
const implementation = this.getImplementation(type) || type; | ||
// if it is not a class (function) | ||
if (!isImplementationType(implementation)) { | ||
@@ -172,3 +180,8 @@ return implementation; | ||
else { | ||
resolvedDependencies[index] = instance; | ||
let enrichedInstance = instance; | ||
const enrichCallback = this.enrichCallbacks.get(dependencyType); | ||
if (typeof enrichCallback === 'function') { | ||
enrichedInstance = enrichCallback(instance); | ||
} | ||
resolvedDependencies[index] = enrichedInstance; | ||
} | ||
@@ -175,0 +188,0 @@ } |
{ | ||
"type": "commonjs", | ||
"version": "4.1.0" | ||
"version": "4.1.1" | ||
} |
@@ -20,7 +20,15 @@ import { CircularDependencyError } from './CircularDependencyError.js'; | ||
let asType = undefined; | ||
const asAnotherType = (type) => { | ||
this.dependencies.delete(implementationType); | ||
this.dependencies.set(type, implementationType); | ||
asType = type; | ||
const enrichCallback = this.enrichCallbacks.get(implementationType); | ||
if (enrichCallback) { | ||
this.enrichCallbacks.delete(implementationType); | ||
this.enrichCallbacks.set(type, enrichCallback); | ||
} | ||
}; | ||
const registeredImplementation = { | ||
as: (type) => { | ||
this.dependencies.delete(implementationType); | ||
this.dependencies.set(type, implementationType); | ||
asType = type; | ||
asAnotherType(type); | ||
return registeredImplementation; | ||
@@ -30,5 +38,3 @@ }, | ||
if (type) { | ||
this.dependencies.delete(implementationType); | ||
this.dependencies.set(type, implementationType); | ||
asType = type; | ||
asAnotherType(type); | ||
} | ||
@@ -93,2 +99,3 @@ if (!isSingleton(implementationType)) { | ||
try { | ||
// return this.internalResolve(type, trace, ...args); | ||
const resolvedInstance = this.internalResolve(type, trace, ...args); | ||
@@ -128,2 +135,3 @@ const enrichCallback = this.enrichCallbacks.get(type); | ||
const implementation = this.getImplementation(type) || type; | ||
// if it is not a class (function) | ||
if (!isImplementationType(implementation)) { | ||
@@ -169,3 +177,8 @@ return implementation; | ||
else { | ||
resolvedDependencies[index] = instance; | ||
let enrichedInstance = instance; | ||
const enrichCallback = this.enrichCallbacks.get(dependencyType); | ||
if (typeof enrichCallback === 'function') { | ||
enrichedInstance = enrichCallback(instance); | ||
} | ||
resolvedDependencies[index] = enrichedInstance; | ||
} | ||
@@ -172,0 +185,0 @@ } |
{ | ||
"type": "module", | ||
"version": "4.1.0" | ||
"version": "4.1.1" | ||
} |
{ | ||
"name": "cheap-di", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "TypeScript dependency injection like Autofac in .Net", | ||
@@ -19,2 +19,7 @@ "type": "module", | ||
], | ||
"main": "./cjs/index.js", | ||
"types": "./types/index.d.ts", | ||
"_main": "./dist/cjs/index.js", | ||
"_module": "./dist/esm/index.js", | ||
"_types": "./dist/types/index.d.ts", | ||
"files": [ | ||
@@ -28,5 +33,3 @@ "cjs/**/*", | ||
], | ||
"main": "./cjs/index.js", | ||
"module": "./esm/index.js", | ||
"types": "./types/index.d.ts" | ||
"module": "./esm/index.js" | ||
} |
@@ -31,3 +31,3 @@ import { cheapDiSymbol } from './cheapDiSymbol.js'; | ||
asSingleton: AsSingleton<TClass, this>; | ||
/** enrich instance when it will be resolved, example, if you want to wrap instance with Proxy */ | ||
/** enrich instance when it will be resolved, for example, if you want to wrap instance with Proxy */ | ||
enrich: Enrich<TClass, this>; | ||
@@ -40,3 +40,3 @@ /** add parameters that will be passed to the class constructor */ | ||
as: AsBase<TInstance, this>; | ||
/** enrich instance when it will be resolved, example, if you want to wrap instance with Proxy */ | ||
/** enrich instance when it will be resolved, for example, if you want to extend it but not right now, and only when it will be resolved */ | ||
enrich: Enrich<TInstance, this>; | ||
@@ -43,0 +43,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
120410
996