@mediaclip/dependency-injection
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -18,28 +18,2 @@ var __defProp = Object.defineProperty; | ||
// src/token.ts | ||
var DiToken = class _DiToken { | ||
constructor(symbol) { | ||
this.symbol = symbol; | ||
this.scope = "singleton"; | ||
} | ||
static create(name) { | ||
return new _DiToken(Symbol(name)); | ||
} | ||
static mergeTokens(a, b, c, d, e, f, g, h) { | ||
return Object.assign(a, b || {}, c || {}, d || {}, e || {}, f || {}, g || {}, h || {}); | ||
} | ||
}; | ||
var ScopedDiToken = class _ScopedDiToken { | ||
constructor(symbol) { | ||
this.symbol = symbol; | ||
this.scope = "scoped"; | ||
} | ||
static mergeTokens(a, b, c, d, e, f, g, h) { | ||
return Object.assign(a, b || {}, c || {}, d || {}, e || {}, f || {}, g || {}, h || {}); | ||
} | ||
static create(name) { | ||
return new _ScopedDiToken(Symbol(name)); | ||
} | ||
}; | ||
// src/utils.ts | ||
@@ -117,6 +91,6 @@ function ident(str, spaces) { | ||
const instance = this.tryResolveFrom(token, this.singletonInstances); | ||
if (instance) | ||
if (instance !== void 0) | ||
return instance; | ||
const newInstance = this.tryResolveSingletonFromFactory(token); | ||
if (newInstance) | ||
if (newInstance !== void 0) | ||
return this.saveSingletonInstance(token, newInstance); | ||
@@ -190,11 +164,11 @@ if (this.scopedFactories.has(token.symbol)) { | ||
tryResolve(token, container) { | ||
if (token instanceof ScopedDiToken) { | ||
if (token.scope === "scoped") { | ||
const instance = this.tryResolveInstance(token); | ||
if (instance) | ||
if (instance !== void 0) | ||
return instance; | ||
const newInstance = this.tryResolveScopedFromFactory(token, container); | ||
if (newInstance) | ||
if (newInstance !== void 0) | ||
return this.saveScopeInstances(token, newInstance); | ||
const parentScopedFactory = this.parentContainer.tryResolveScopedFactory(token); | ||
if (parentScopedFactory) { | ||
if (parentScopedFactory !== void 0) { | ||
return this.saveScopeInstances(token, parentScopedFactory(container != null ? container : this)); | ||
@@ -204,11 +178,11 @@ } | ||
const parentInstance = this.parentContainer.tryResolve(token, container); | ||
if (parentInstance) | ||
if (parentInstance !== void 0) | ||
return parentInstance; | ||
} | ||
} else if (token instanceof DiToken) { | ||
} else if (token.scope === "singleton") { | ||
const singletonInstance = super.tryResolve(token); | ||
if (singletonInstance) { | ||
if (singletonInstance !== void 0) { | ||
return singletonInstance; | ||
} | ||
return this.parentContainer.tryResolve(token); | ||
return this.parentContainer.tryResolve(token, container); | ||
} | ||
@@ -257,2 +231,28 @@ } | ||
}; | ||
// src/token.ts | ||
var DiToken = class _DiToken { | ||
constructor(symbol) { | ||
this.symbol = symbol; | ||
this.scope = "singleton"; | ||
} | ||
static create(name) { | ||
return new _DiToken(Symbol(name)); | ||
} | ||
static mergeTokens(a, b, c, d, e, f, g, h) { | ||
return Object.assign(a, b || {}, c || {}, d || {}, e || {}, f || {}, g || {}, h || {}); | ||
} | ||
}; | ||
var ScopedDiToken = class _ScopedDiToken { | ||
constructor(symbol) { | ||
this.symbol = symbol; | ||
this.scope = "scoped"; | ||
} | ||
static mergeTokens(a, b, c, d, e, f, g, h) { | ||
return Object.assign(a, b || {}, c || {}, d || {}, e || {}, f || {}, g || {}, h || {}); | ||
} | ||
static create(name) { | ||
return new _ScopedDiToken(Symbol(name)); | ||
} | ||
}; | ||
export { | ||
@@ -259,0 +259,0 @@ DiContainer, |
@@ -7,3 +7,3 @@ { | ||
"name": "@mediaclip/dependency-injection", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"main": "./dist/index.js", | ||
@@ -10,0 +10,0 @@ "keywords": [ |
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
70364