@appolo/inject
Advanced tools
Comparing version 8.0.13 to 8.0.14
@@ -5,3 +5,3 @@ import {Injector} from "./lib/inject/inject"; | ||
export {IDefinition, IParamInject} from './lib/interfaces/IDefinition' | ||
export {IFactory} from './lib/interfaces/IFactory' | ||
export {IFactory,FactoryFn} from './lib/interfaces/IFactory' | ||
export {IOptions} from './lib/interfaces/IOptions' | ||
@@ -8,0 +8,0 @@ export {Injector} from './lib/inject/inject' |
export interface IFactory<T> { | ||
get(): T | Promise<T> | ||
} | ||
} | ||
export type FactoryFn<T extends new (...args: any) => any> = (...args: ConstructorParameters<T>) => InstanceType<T> |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._defineProperty = void 0; | ||
function _defineProperty(object, name, fn, cache = false) { | ||
function _defineProperty(object, name, fn, cache = false, addSelf = false) { | ||
let $self = this; | ||
@@ -9,3 +9,3 @@ if (!cache) { | ||
get() { | ||
return fn($self); | ||
return addSelf ? fn($self) : fn(); | ||
}, configurable: true | ||
@@ -23,3 +23,3 @@ }); | ||
} | ||
let value = fn($self); | ||
let value = addSelf ? fn($self) : fn(); | ||
func.__cached__[name] = value; | ||
@@ -26,0 +26,0 @@ return value; |
import {Injector} from "../../inject/inject"; | ||
export function _defineProperty(this: Injector, object: any, name: string, fn: Function, cache: boolean = false) { | ||
export function _defineProperty(this: Injector, object: any, name: string, fn: Function, cache: boolean = false,addSelf = false) { | ||
let $self = this; | ||
@@ -8,3 +8,3 @@ if (!cache) { | ||
get() { | ||
return fn($self); | ||
return addSelf ?fn($self):fn(); | ||
}, configurable: true | ||
@@ -30,3 +30,3 @@ }); | ||
let value = fn($self); | ||
let value = addSelf ?fn($self):fn(); | ||
@@ -33,0 +33,0 @@ func.__cached__[name] = value; |
@@ -30,3 +30,3 @@ "use strict"; | ||
if (prop.lazy) { | ||
_defineProperty_1._defineProperty.call(this, object, prop.name, util_1.Util.createDelegate(_getByParamObj_1._getByParamObj, this, [prop, prop.ref]), true); | ||
_defineProperty_1._defineProperty.call(this, object, prop.name, util_1.Util.createDelegate(_getByParamObj_1._getByParamObj, this, [prop, prop.ref]), true, false); | ||
} | ||
@@ -54,3 +54,3 @@ else { | ||
else if (prop.lazyFn) { | ||
_defineProperty_1._defineProperty.call(this, object, prop.name, prop.lazyFn); | ||
_defineProperty_1._defineProperty.call(this, object, prop.name, prop.lazyFn, false, true); | ||
} | ||
@@ -57,0 +57,0 @@ } |
@@ -35,3 +35,3 @@ import {IDefinition, IParamInject} from "../../interfaces/IDefinition"; | ||
if (prop.lazy) { | ||
_defineProperty.call(this,object, prop.name, Util.createDelegate(_getByParamObj, this, [ prop, prop.ref]), true) | ||
_defineProperty.call(this,object, prop.name, Util.createDelegate(_getByParamObj, this, [ prop, prop.ref]), true,false) | ||
} else { | ||
@@ -61,3 +61,3 @@ object[prop.name] = _getByParamObj.call(this, prop, prop.ref); | ||
} else if (prop.lazyFn) { | ||
_defineProperty.call(this,object, prop.name, prop.lazyFn) | ||
_defineProperty.call(this,object, prop.name, prop.lazyFn,false,true) | ||
@@ -64,0 +64,0 @@ } |
@@ -34,3 +34,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.13", | ||
"version": "8.0.14", | ||
"license": "MIT", | ||
@@ -37,0 +37,0 @@ "repository": { |
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
221516
3400