@wessberg/di
Advanced tools
Comparing version 1.0.24 to 1.0.25
@@ -0,1 +1,11 @@ | ||
<a name="1.0.25"></a> | ||
## 1.0.25 (2017-09-10) | ||
* 1.0.25 ([ec30aea](https://github.com/wessberg/di/commit/ec30aea)) | ||
* Added better diagnostics ([26c0b7d](https://github.com/wessberg/di/commit/26c0b7d)) | ||
* Bumped version ([14dfb3e](https://github.com/wessberg/di/commit/14dfb3e)) | ||
* Fixed JSDoc ([e927f24](https://github.com/wessberg/di/commit/e927f24)) | ||
<a name="1.0.24"></a> | ||
@@ -2,0 +12,0 @@ ## 1.0.24 (2017-09-03) |
@@ -88,5 +88,6 @@ import { IDIContainer } from "./i-di-container"; | ||
* @param {string} identifier | ||
* @param {string} [parent] | ||
* @returns {IRegistrationRecord<T,U>} | ||
*/ | ||
private getRegistrationRecord<T, U>(identifier); | ||
private getRegistrationRecord<T, U>({identifier, parent}); | ||
/** | ||
@@ -105,4 +106,4 @@ * Caches the given instance so that it can be retrieved in the future. | ||
*/ | ||
private constructInstance<T>({identifier}); | ||
private constructInstance<T>({identifier, parent}); | ||
} | ||
export declare const DIContainer: DIServiceContainer; |
@@ -115,8 +115,9 @@ import { RegistrationKind } from "../registration-kind/registration-kind"; | ||
* @param {string} identifier | ||
* @param {string} [parent] | ||
* @returns {IRegistrationRecord<T,U>} | ||
*/ | ||
getRegistrationRecord(identifier) { | ||
getRegistrationRecord({ identifier, parent }) { | ||
const record = this.serviceRegistry.get(identifier); | ||
if (record == null) | ||
throw new ReferenceError(`${this.constructor.name} could not get registration record: No implementation was found!`); | ||
throw new ReferenceError(`${this.constructor.name} could not find a service for identifier: "${identifier}". ${parent == null ? "" : `It is required by the service: '${parent}'.`} Remember to register it as a service!`); | ||
return record; | ||
@@ -140,4 +141,4 @@ } | ||
*/ | ||
constructInstance({ identifier }) { | ||
const registrationRecord = this.getRegistrationRecord(identifier); | ||
constructInstance({ identifier, parent }) { | ||
const registrationRecord = this.getRegistrationRecord({ identifier, parent }); | ||
// If an instance already exists (and it is a singleton), return that one | ||
@@ -159,3 +160,3 @@ if (this.hasInstance(identifier) && registrationRecord.kind === RegistrationKind.SINGLETON) { | ||
// Instantiate all of the argument services (or re-use them if they were registered as singletons) | ||
const instanceArgs = mappedArgs.map((dep) => dep === undefined ? undefined : this.constructInstance({ identifier: dep })); | ||
const instanceArgs = mappedArgs.map((dep) => dep === undefined ? undefined : this.constructInstance({ identifier: dep, parent: identifier })); | ||
try { | ||
@@ -162,0 +163,0 @@ // Try to construct an instance with 'new' and if it fails, call the implementation directly. |
@@ -88,5 +88,6 @@ import { IDIContainer } from "./i-di-container"; | ||
* @param {string} identifier | ||
* @param {string} [parent] | ||
* @returns {IRegistrationRecord<T,U>} | ||
*/ | ||
private getRegistrationRecord<T, U>(identifier); | ||
private getRegistrationRecord<T, U>({identifier, parent}); | ||
/** | ||
@@ -105,4 +106,4 @@ * Caches the given instance so that it can be retrieved in the future. | ||
*/ | ||
private constructInstance<T>({identifier}); | ||
private constructInstance<T>({identifier, parent}); | ||
} | ||
export declare const DIContainer: DIServiceContainer; |
@@ -126,8 +126,9 @@ (function (factory) { | ||
* @param {string} identifier | ||
* @param {string} [parent] | ||
* @returns {IRegistrationRecord<T,U>} | ||
*/ | ||
getRegistrationRecord(identifier) { | ||
getRegistrationRecord({ identifier, parent }) { | ||
const record = this.serviceRegistry.get(identifier); | ||
if (record == null) | ||
throw new ReferenceError(`${this.constructor.name} could not get registration record: No implementation was found!`); | ||
throw new ReferenceError(`${this.constructor.name} could not find a service for identifier: "${identifier}". ${parent == null ? "" : `It is required by the service: '${parent}'.`} Remember to register it as a service!`); | ||
return record; | ||
@@ -151,4 +152,4 @@ } | ||
*/ | ||
constructInstance({ identifier }) { | ||
const registrationRecord = this.getRegistrationRecord(identifier); | ||
constructInstance({ identifier, parent }) { | ||
const registrationRecord = this.getRegistrationRecord({ identifier, parent }); | ||
// If an instance already exists (and it is a singleton), return that one | ||
@@ -170,3 +171,3 @@ if (this.hasInstance(identifier) && registrationRecord.kind === registration_kind_1.RegistrationKind.SINGLETON) { | ||
// Instantiate all of the argument services (or re-use them if they were registered as singletons) | ||
const instanceArgs = mappedArgs.map((dep) => dep === undefined ? undefined : this.constructInstance({ identifier: dep })); | ||
const instanceArgs = mappedArgs.map((dep) => dep === undefined ? undefined : this.constructInstance({ identifier: dep, parent: identifier })); | ||
try { | ||
@@ -173,0 +174,0 @@ // Try to construct an instance with 'new' and if it fails, call the implementation directly. |
{ | ||
"name": "@wessberg/di", | ||
"version": "1.0.24", | ||
"version": "1.0.25", | ||
"description": "A Dependency-Injection container that holds services and can produce instances of them as required. It mimics reflection by parsing the app at compile-time and supporting the generic-reflection syntax.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
64359
82
844
0