@artus/injection
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -59,3 +59,3 @@ "use strict"; | ||
exports.LazyInjectConstructorError = LazyInjectConstructorError; | ||
class ScopeEscapeError extends (0, base_error_1.createErrorClass)('SingletonInjectExecutionError') { | ||
class ScopeEscapeError extends (0, base_error_1.createErrorClass)('ScopeEscapeError') { | ||
constructor(target, propertyOrIndex, classScope, propScope) { | ||
@@ -62,0 +62,0 @@ super(() => { |
@@ -7,3 +7,6 @@ import Container from './container'; | ||
constructor(ctx: any, parent: ContainerType); | ||
get<T = unknown>(id: Identifier<T>): T; | ||
get<T = unknown>(id: Identifier<T>, options?: { | ||
noThrow?: boolean; | ||
defaultValue?: any; | ||
}): T; | ||
getCtx(): any; | ||
@@ -10,0 +13,0 @@ getHandler(name: string | symbol): HandlerFunction | undefined; |
@@ -16,6 +16,9 @@ "use strict"; | ||
} | ||
get(id) { | ||
get(id, options = {}) { | ||
var _a; | ||
const md = (_a = this.getDefinition(id)) !== null && _a !== void 0 ? _a : this.parent.getDefinition(id); | ||
if (!md) { | ||
if (options.noThrow) { | ||
return options.defaultValue; | ||
} | ||
throw new error_1.NotFoundError(id); | ||
@@ -22,0 +25,0 @@ } |
@@ -52,3 +52,6 @@ export declare type Constructable<T = unknown> = new (...args: any[]) => T; | ||
export interface ContainerType { | ||
get<T>(id: Identifier<T>): T; | ||
get<T>(id: Identifier<T>, options?: { | ||
noThrow?: boolean; | ||
defaultValue?: any; | ||
}): T; | ||
set(options: Partial<InjectableDefinition>): this; | ||
@@ -55,0 +58,0 @@ getDefinition(id: Identifier): InjectableMetadata | undefined; |
{ | ||
"name": "@artus/injection", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "A IoC Implemention for Artus.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
57706
914