@wendellhu/redi
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -306,3 +306,2 @@ (function (global, factory) { | ||
var _this = this; | ||
this.dependencies = dependencies; | ||
this.dependencyMap = new Map(); | ||
@@ -436,2 +435,18 @@ this.normalizeDependencies(dependencies).map(function (pair) { return _this.add(pair[0], pair[1]); }); | ||
function changeToSelf(target, index, withNew) { | ||
var descriptor = getDependencyByIndex(target, index); | ||
descriptor.withNew = withNew; | ||
} | ||
function withNewDecoratorFactoryProducer(withNew) { | ||
return function DecoratorFactory() { | ||
if (this instanceof DecoratorFactory) { | ||
return this; | ||
} | ||
return function (target, _key, index) { | ||
changeToSelf(target, index, withNew); | ||
}; | ||
}; | ||
} | ||
var WithNew = withNewDecoratorFactoryProducer(true); | ||
function normalizeFactoryDeps(deps) { | ||
@@ -447,2 +462,3 @@ if (!deps) { | ||
quantity: exports.Quantity.REQUIRED, | ||
withNew: false, | ||
}; | ||
@@ -454,2 +470,3 @@ } | ||
var quantity = exports.Quantity.REQUIRED; | ||
var withNew = false; | ||
modifiers.forEach(function (modifier) { | ||
@@ -465,5 +482,11 @@ if (modifier instanceof Self) { | ||
} | ||
else { | ||
else if (modifier instanceof Many) { | ||
quantity = exports.Quantity.MANY; | ||
} | ||
else if (modifier instanceof WithNew) { | ||
withNew = true; | ||
} | ||
else { | ||
throw new RediError("unknown dep modifier ".concat(modifier, ".")); | ||
} | ||
}); | ||
@@ -475,2 +498,3 @@ return { | ||
lookUp: lookUp, | ||
withNew: withNew, | ||
}; | ||
@@ -731,3 +755,3 @@ }); | ||
}; | ||
Injector.prototype._get = function (id, quantityOrLookup, lookUp) { | ||
Injector.prototype._get = function (id, quantityOrLookup, lookUp, toSelf) { | ||
this.ensureInjectorNotDisposed(); | ||
@@ -743,9 +767,11 @@ var quantity = exports.Quantity.REQUIRED; | ||
} | ||
// see if the dependency is already resolved, return it and check quantity | ||
var cachedResult = this.getValue(id, quantity, lookUp); | ||
if (cachedResult !== NotInstantiatedSymbol) { | ||
return cachedResult; | ||
if (!toSelf) { | ||
// see if the dependency is already resolved, return it and check quantity | ||
var cachedResult = this.getValue(id, quantity, lookUp); | ||
if (cachedResult !== NotInstantiatedSymbol) { | ||
return cachedResult; | ||
} | ||
} | ||
// see if the dependency can be instantiated by itself or its parent | ||
return this.createAndCacheDependency(id, quantity, lookUp); | ||
return this.createDependency(id, quantity, lookUp, !toSelf); | ||
}; | ||
@@ -761,3 +787,3 @@ /** | ||
} | ||
var newResult = this.createAndCacheDependency(id, exports.Quantity.REQUIRED); | ||
var newResult = this.createDependency(id, exports.Quantity.REQUIRED); | ||
if (!isAsyncHook(newResult)) { | ||
@@ -782,3 +808,4 @@ return Promise.resolve(newResult); | ||
*/ | ||
Injector.prototype.resolveDependency = function (id, item) { | ||
Injector.prototype.resolveDependency = function (id, item, shouldCache) { | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
if (isValueDependencyItem(item)) { | ||
@@ -788,6 +815,6 @@ return this.resolveValueDependency(id, item); | ||
else if (isFactoryDependencyItem(item)) { | ||
return this.resolveFactory(id, item); | ||
return this.resolveFactory(id, item, shouldCache); | ||
} | ||
else if (isClassDependencyItem(item)) { | ||
return this.resolveClass(id, item); | ||
return this.resolveClass(id, item, shouldCache); | ||
} | ||
@@ -803,4 +830,5 @@ else { | ||
}; | ||
Injector.prototype.resolveClass = function (id, item) { | ||
Injector.prototype.resolveClass = function (id, item, shouldCache) { | ||
var _this = this; | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
var ctor = item.useClass; | ||
@@ -838,3 +866,3 @@ var thing; | ||
} | ||
if (id) { | ||
if (id && shouldCache) { | ||
this.resolvedDependencyCollection.add(id, thing); | ||
@@ -856,3 +884,4 @@ } | ||
var dep = declaredDependencies_1[_a]; | ||
var thing_1 = this._get(dep.identifier, dep.quantity, dep.lookUp); // recursive happens here | ||
// recursive happens here | ||
var thing_1 = this._get(dep.identifier, dep.quantity, dep.lookUp, dep.withNew); | ||
resolvedArgs.push(thing_1); | ||
@@ -876,3 +905,3 @@ } | ||
}; | ||
Injector.prototype.resolveFactory = function (id, item) { | ||
Injector.prototype.resolveFactory = function (id, item, shouldCache) { | ||
this.markNewResolution(id); | ||
@@ -883,7 +912,9 @@ var declaredDependencies = normalizeFactoryDeps(item.deps); | ||
var dep = declaredDependencies_2[_i]; | ||
var thing_2 = this.get(dep.identifier, dep.quantity, dep.lookUp); | ||
var thing_2 = this._get(dep.identifier, dep.quantity, dep.lookUp, dep.withNew); | ||
resolvedArgs.push(thing_2); | ||
} | ||
var thing = item.useFactory.apply(null, resolvedArgs); | ||
this.resolvedDependencyCollection.add(id, thing); | ||
if (shouldCache) { | ||
this.resolvedDependencyCollection.add(id, thing); | ||
} | ||
this.markResolutionCompleted(); | ||
@@ -962,5 +993,6 @@ return thing; | ||
*/ | ||
Injector.prototype.createAndCacheDependency = function (id, quantity, lookUp) { | ||
Injector.prototype.createDependency = function (id, quantity, lookUp, shouldCache) { | ||
var _this = this; | ||
if (quantity === void 0) { quantity = exports.Quantity.REQUIRED; } | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
var onSelf = function () { | ||
@@ -970,6 +1002,6 @@ var registrations = _this.dependencyCollection.get(id, quantity); | ||
if (Array.isArray(registrations)) { | ||
ret = registrations.map(function (dependencyItem) { return _this.resolveDependency(id, dependencyItem); }); | ||
ret = registrations.map(function (dependencyItem) { return _this.resolveDependency(id, dependencyItem, shouldCache); }); | ||
} | ||
else if (registrations) { | ||
ret = _this.resolveDependency(id, registrations); | ||
ret = _this.resolveDependency(id, registrations, shouldCache); | ||
} | ||
@@ -980,3 +1012,3 @@ return ret; | ||
if (_this.parent) { | ||
return _this.parent.createAndCacheDependency(id, quantity); | ||
return _this.parent.createDependency(id, quantity, undefined, shouldCache); | ||
} | ||
@@ -1038,2 +1070,3 @@ else { | ||
exports.SkipSelf = SkipSelf; | ||
exports.WithNew = WithNew; | ||
exports.createIdentifier = createIdentifier; | ||
@@ -1040,0 +1073,0 @@ exports.forwardRef = forwardRef; |
@@ -19,3 +19,2 @@ import { DependencyIdentifier } from './dependencyIdentifier'; | ||
export declare class DependencyCollection implements Disposable { | ||
private readonly dependencies; | ||
private readonly dependencyMap; | ||
@@ -53,4 +52,4 @@ constructor(dependencies: Dependency[]); | ||
get<T>(id: DependencyIdentifier<T>, quantity: Quantity.MANY): T[]; | ||
get<T>(id: DependencyIdentifier<T>, quantity: Quantity): T[]; | ||
get<T>(id: DependencyIdentifier<T>, quantity: Quantity): T[] | T | null; | ||
dispose(): void; | ||
} |
@@ -41,3 +41,2 @@ var __extends = (this && this.__extends) || (function () { | ||
var _this = this; | ||
this.dependencies = dependencies; | ||
this.dependencyMap = new Map(); | ||
@@ -44,0 +43,0 @@ this.normalizeDependencies(dependencies).map(function (pair) { return _this.add(pair[0], pair[1]); }); |
@@ -9,2 +9,3 @@ import { DependencyIdentifier } from './dependencyIdentifier'; | ||
lookUp?: LookUp; | ||
withNew: boolean; | ||
} | ||
@@ -11,0 +12,0 @@ /** |
import { Self, SkipSelf } from './dependencyLookUp'; | ||
import { Optional } from './dependencyQuantity'; | ||
import { Many, Optional } from './dependencyQuantity'; | ||
import { WithNew } from './dependencyWithNew'; | ||
import { RediError } from './error'; | ||
import { LookUp, Quantity } from './types'; | ||
@@ -14,2 +16,3 @@ export function normalizeFactoryDeps(deps) { | ||
quantity: Quantity.REQUIRED, | ||
withNew: false, | ||
}; | ||
@@ -21,2 +24,3 @@ } | ||
var quantity = Quantity.REQUIRED; | ||
var withNew = false; | ||
modifiers.forEach(function (modifier) { | ||
@@ -32,5 +36,11 @@ if (modifier instanceof Self) { | ||
} | ||
else { | ||
else if (modifier instanceof Many) { | ||
quantity = Quantity.MANY; | ||
} | ||
else if (modifier instanceof WithNew) { | ||
withNew = true; | ||
} | ||
else { | ||
throw new RediError("unknown dep modifier ".concat(modifier, ".")); | ||
} | ||
}); | ||
@@ -42,2 +52,3 @@ return { | ||
lookUp: lookUp, | ||
withNew: withNew, | ||
}; | ||
@@ -44,0 +55,0 @@ }); |
import { DependencyIdentifier } from './dependencyIdentifier'; | ||
import { Self, SkipSelf } from './dependencyLookUp'; | ||
import { Many, Optional } from './dependencyQuantity'; | ||
import { WithNew } from './dependencyWithNew'; | ||
export interface Ctor<T> { | ||
@@ -14,3 +15,3 @@ new (...args: any[]): T; | ||
export declare function isClassDependencyItem<T>(thing: unknown): thing is ClassDependencyItem<T>; | ||
export declare type FactoryDepModifier = typeof Self | typeof SkipSelf | typeof Optional | typeof Many; | ||
export declare type FactoryDepModifier = typeof Self | typeof SkipSelf | typeof Optional | typeof Many | typeof WithNew; | ||
export declare type FactoryDep<T> = [...FactoryDepModifier[], DependencyIdentifier<T>] | DependencyIdentifier<T>; | ||
@@ -17,0 +18,0 @@ export interface FactoryDependencyItem<T> { |
@@ -31,3 +31,3 @@ import { Dependency, DependencyPair } from './dependencyCollection'; | ||
get<T>(id: DependencyIdentifier<T>, quantityOrLookup?: Quantity | LookUp, lookUp?: LookUp): T[] | T | null; | ||
_get<T>(id: DependencyIdentifier<T>, quantityOrLookup?: Quantity | LookUp, lookUp?: LookUp): T[] | T | AsyncHook<T> | null; | ||
_get<T>(id: DependencyIdentifier<T>, quantityOrLookup?: Quantity | LookUp, lookUp?: LookUp, toSelf?: boolean): T[] | T | AsyncHook<T> | null; | ||
/** | ||
@@ -58,3 +58,3 @@ * get a dependency, but in async way | ||
*/ | ||
private createAndCacheDependency; | ||
private createDependency; | ||
private markNewResolution; | ||
@@ -61,0 +61,0 @@ private markResolutionCompleted; |
@@ -136,3 +136,3 @@ var __extends = (this && this.__extends) || (function () { | ||
}; | ||
Injector.prototype._get = function (id, quantityOrLookup, lookUp) { | ||
Injector.prototype._get = function (id, quantityOrLookup, lookUp, toSelf) { | ||
this.ensureInjectorNotDisposed(); | ||
@@ -148,9 +148,11 @@ var quantity = Quantity.REQUIRED; | ||
} | ||
// see if the dependency is already resolved, return it and check quantity | ||
var cachedResult = this.getValue(id, quantity, lookUp); | ||
if (cachedResult !== NotInstantiatedSymbol) { | ||
return cachedResult; | ||
if (!toSelf) { | ||
// see if the dependency is already resolved, return it and check quantity | ||
var cachedResult = this.getValue(id, quantity, lookUp); | ||
if (cachedResult !== NotInstantiatedSymbol) { | ||
return cachedResult; | ||
} | ||
} | ||
// see if the dependency can be instantiated by itself or its parent | ||
return this.createAndCacheDependency(id, quantity, lookUp); | ||
return this.createDependency(id, quantity, lookUp, !toSelf); | ||
}; | ||
@@ -166,3 +168,3 @@ /** | ||
} | ||
var newResult = this.createAndCacheDependency(id, Quantity.REQUIRED); | ||
var newResult = this.createDependency(id, Quantity.REQUIRED); | ||
if (!isAsyncHook(newResult)) { | ||
@@ -187,3 +189,4 @@ return Promise.resolve(newResult); | ||
*/ | ||
Injector.prototype.resolveDependency = function (id, item) { | ||
Injector.prototype.resolveDependency = function (id, item, shouldCache) { | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
if (isValueDependencyItem(item)) { | ||
@@ -193,6 +196,6 @@ return this.resolveValueDependency(id, item); | ||
else if (isFactoryDependencyItem(item)) { | ||
return this.resolveFactory(id, item); | ||
return this.resolveFactory(id, item, shouldCache); | ||
} | ||
else if (isClassDependencyItem(item)) { | ||
return this.resolveClass(id, item); | ||
return this.resolveClass(id, item, shouldCache); | ||
} | ||
@@ -208,4 +211,5 @@ else { | ||
}; | ||
Injector.prototype.resolveClass = function (id, item) { | ||
Injector.prototype.resolveClass = function (id, item, shouldCache) { | ||
var _this = this; | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
var ctor = item.useClass; | ||
@@ -243,3 +247,3 @@ var thing; | ||
} | ||
if (id) { | ||
if (id && shouldCache) { | ||
this.resolvedDependencyCollection.add(id, thing); | ||
@@ -261,3 +265,4 @@ } | ||
var dep = declaredDependencies_1[_a]; | ||
var thing_1 = this._get(dep.identifier, dep.quantity, dep.lookUp); // recursive happens here | ||
// recursive happens here | ||
var thing_1 = this._get(dep.identifier, dep.quantity, dep.lookUp, dep.withNew); | ||
resolvedArgs.push(thing_1); | ||
@@ -281,3 +286,3 @@ } | ||
}; | ||
Injector.prototype.resolveFactory = function (id, item) { | ||
Injector.prototype.resolveFactory = function (id, item, shouldCache) { | ||
this.markNewResolution(id); | ||
@@ -288,7 +293,9 @@ var declaredDependencies = normalizeFactoryDeps(item.deps); | ||
var dep = declaredDependencies_2[_i]; | ||
var thing_2 = this.get(dep.identifier, dep.quantity, dep.lookUp); | ||
var thing_2 = this._get(dep.identifier, dep.quantity, dep.lookUp, dep.withNew); | ||
resolvedArgs.push(thing_2); | ||
} | ||
var thing = item.useFactory.apply(null, resolvedArgs); | ||
this.resolvedDependencyCollection.add(id, thing); | ||
if (shouldCache) { | ||
this.resolvedDependencyCollection.add(id, thing); | ||
} | ||
this.markResolutionCompleted(); | ||
@@ -367,5 +374,6 @@ return thing; | ||
*/ | ||
Injector.prototype.createAndCacheDependency = function (id, quantity, lookUp) { | ||
Injector.prototype.createDependency = function (id, quantity, lookUp, shouldCache) { | ||
var _this = this; | ||
if (quantity === void 0) { quantity = Quantity.REQUIRED; } | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
var onSelf = function () { | ||
@@ -375,6 +383,6 @@ var registrations = _this.dependencyCollection.get(id, quantity); | ||
if (Array.isArray(registrations)) { | ||
ret = registrations.map(function (dependencyItem) { return _this.resolveDependency(id, dependencyItem); }); | ||
ret = registrations.map(function (dependencyItem) { return _this.resolveDependency(id, dependencyItem, shouldCache); }); | ||
} | ||
else if (registrations) { | ||
ret = _this.resolveDependency(id, registrations); | ||
ret = _this.resolveDependency(id, registrations, shouldCache); | ||
} | ||
@@ -385,3 +393,3 @@ return ret; | ||
if (_this.parent) { | ||
return _this.parent.createAndCacheDependency(id, quantity); | ||
return _this.parent.createDependency(id, quantity, undefined, shouldCache); | ||
} | ||
@@ -388,0 +396,0 @@ else { |
@@ -12,3 +12,4 @@ export { createIdentifier } from './decorators'; | ||
export { registerSingleton } from './dependencySingletons'; | ||
export { AsyncDependencyItem, ClassDependencyItem, Ctor, DependencyItem, FactoryDependencyItem, isAsyncDependencyItem, isAsyncHook, isClassDependencyItem, isCtor, isFactoryDependencyItem, isValueDependencyItem, SyncDependencyItem, ValueDependencyItem, } from './dependencyItem'; | ||
export { WithNew } from './dependencyWithNew'; | ||
export { AsyncDependencyItem, AsyncHook, ClassDependencyItem, Ctor, DependencyItem, FactoryDependencyItem, isAsyncDependencyItem, isAsyncHook, isClassDependencyItem, isCtor, isFactoryDependencyItem, isValueDependencyItem, SyncDependencyItem, ValueDependencyItem, } from './dependencyItem'; | ||
export { RediError } from './error'; |
@@ -9,4 +9,5 @@ export { createIdentifier } from './decorators'; | ||
export { registerSingleton } from './dependencySingletons'; | ||
export { WithNew } from './dependencyWithNew'; | ||
export { isAsyncDependencyItem, isAsyncHook, isClassDependencyItem, isCtor, isFactoryDependencyItem, isValueDependencyItem, } from './dependencyItem'; | ||
export { RediError } from './error'; | ||
//# sourceMappingURL=publicApi.js.map |
@@ -300,3 +300,2 @@ var IdentifierDecoratorSymbol = Symbol('$$IDENTIFIER_DECORATOR'); | ||
var _this = this; | ||
this.dependencies = dependencies; | ||
this.dependencyMap = new Map(); | ||
@@ -430,2 +429,18 @@ this.normalizeDependencies(dependencies).map(function (pair) { return _this.add(pair[0], pair[1]); }); | ||
function changeToSelf(target, index, withNew) { | ||
var descriptor = getDependencyByIndex(target, index); | ||
descriptor.withNew = withNew; | ||
} | ||
function withNewDecoratorFactoryProducer(withNew) { | ||
return function DecoratorFactory() { | ||
if (this instanceof DecoratorFactory) { | ||
return this; | ||
} | ||
return function (target, _key, index) { | ||
changeToSelf(target, index, withNew); | ||
}; | ||
}; | ||
} | ||
var WithNew = withNewDecoratorFactoryProducer(true); | ||
function normalizeFactoryDeps(deps) { | ||
@@ -441,2 +456,3 @@ if (!deps) { | ||
quantity: Quantity.REQUIRED, | ||
withNew: false, | ||
}; | ||
@@ -448,2 +464,3 @@ } | ||
var quantity = Quantity.REQUIRED; | ||
var withNew = false; | ||
modifiers.forEach(function (modifier) { | ||
@@ -459,5 +476,11 @@ if (modifier instanceof Self) { | ||
} | ||
else { | ||
else if (modifier instanceof Many) { | ||
quantity = Quantity.MANY; | ||
} | ||
else if (modifier instanceof WithNew) { | ||
withNew = true; | ||
} | ||
else { | ||
throw new RediError("unknown dep modifier ".concat(modifier, ".")); | ||
} | ||
}); | ||
@@ -469,2 +492,3 @@ return { | ||
lookUp: lookUp, | ||
withNew: withNew, | ||
}; | ||
@@ -725,3 +749,3 @@ }); | ||
}; | ||
Injector.prototype._get = function (id, quantityOrLookup, lookUp) { | ||
Injector.prototype._get = function (id, quantityOrLookup, lookUp, toSelf) { | ||
this.ensureInjectorNotDisposed(); | ||
@@ -737,9 +761,11 @@ var quantity = Quantity.REQUIRED; | ||
} | ||
// see if the dependency is already resolved, return it and check quantity | ||
var cachedResult = this.getValue(id, quantity, lookUp); | ||
if (cachedResult !== NotInstantiatedSymbol) { | ||
return cachedResult; | ||
if (!toSelf) { | ||
// see if the dependency is already resolved, return it and check quantity | ||
var cachedResult = this.getValue(id, quantity, lookUp); | ||
if (cachedResult !== NotInstantiatedSymbol) { | ||
return cachedResult; | ||
} | ||
} | ||
// see if the dependency can be instantiated by itself or its parent | ||
return this.createAndCacheDependency(id, quantity, lookUp); | ||
return this.createDependency(id, quantity, lookUp, !toSelf); | ||
}; | ||
@@ -755,3 +781,3 @@ /** | ||
} | ||
var newResult = this.createAndCacheDependency(id, Quantity.REQUIRED); | ||
var newResult = this.createDependency(id, Quantity.REQUIRED); | ||
if (!isAsyncHook(newResult)) { | ||
@@ -776,3 +802,4 @@ return Promise.resolve(newResult); | ||
*/ | ||
Injector.prototype.resolveDependency = function (id, item) { | ||
Injector.prototype.resolveDependency = function (id, item, shouldCache) { | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
if (isValueDependencyItem(item)) { | ||
@@ -782,6 +809,6 @@ return this.resolveValueDependency(id, item); | ||
else if (isFactoryDependencyItem(item)) { | ||
return this.resolveFactory(id, item); | ||
return this.resolveFactory(id, item, shouldCache); | ||
} | ||
else if (isClassDependencyItem(item)) { | ||
return this.resolveClass(id, item); | ||
return this.resolveClass(id, item, shouldCache); | ||
} | ||
@@ -797,4 +824,5 @@ else { | ||
}; | ||
Injector.prototype.resolveClass = function (id, item) { | ||
Injector.prototype.resolveClass = function (id, item, shouldCache) { | ||
var _this = this; | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
var ctor = item.useClass; | ||
@@ -832,3 +860,3 @@ var thing; | ||
} | ||
if (id) { | ||
if (id && shouldCache) { | ||
this.resolvedDependencyCollection.add(id, thing); | ||
@@ -850,3 +878,4 @@ } | ||
var dep = declaredDependencies_1[_a]; | ||
var thing_1 = this._get(dep.identifier, dep.quantity, dep.lookUp); // recursive happens here | ||
// recursive happens here | ||
var thing_1 = this._get(dep.identifier, dep.quantity, dep.lookUp, dep.withNew); | ||
resolvedArgs.push(thing_1); | ||
@@ -870,3 +899,3 @@ } | ||
}; | ||
Injector.prototype.resolveFactory = function (id, item) { | ||
Injector.prototype.resolveFactory = function (id, item, shouldCache) { | ||
this.markNewResolution(id); | ||
@@ -877,7 +906,9 @@ var declaredDependencies = normalizeFactoryDeps(item.deps); | ||
var dep = declaredDependencies_2[_i]; | ||
var thing_2 = this.get(dep.identifier, dep.quantity, dep.lookUp); | ||
var thing_2 = this._get(dep.identifier, dep.quantity, dep.lookUp, dep.withNew); | ||
resolvedArgs.push(thing_2); | ||
} | ||
var thing = item.useFactory.apply(null, resolvedArgs); | ||
this.resolvedDependencyCollection.add(id, thing); | ||
if (shouldCache) { | ||
this.resolvedDependencyCollection.add(id, thing); | ||
} | ||
this.markResolutionCompleted(); | ||
@@ -956,5 +987,6 @@ return thing; | ||
*/ | ||
Injector.prototype.createAndCacheDependency = function (id, quantity, lookUp) { | ||
Injector.prototype.createDependency = function (id, quantity, lookUp, shouldCache) { | ||
var _this = this; | ||
if (quantity === void 0) { quantity = Quantity.REQUIRED; } | ||
if (shouldCache === void 0) { shouldCache = true; } | ||
var onSelf = function () { | ||
@@ -964,6 +996,6 @@ var registrations = _this.dependencyCollection.get(id, quantity); | ||
if (Array.isArray(registrations)) { | ||
ret = registrations.map(function (dependencyItem) { return _this.resolveDependency(id, dependencyItem); }); | ||
ret = registrations.map(function (dependencyItem) { return _this.resolveDependency(id, dependencyItem, shouldCache); }); | ||
} | ||
else if (registrations) { | ||
ret = _this.resolveDependency(id, registrations); | ||
ret = _this.resolveDependency(id, registrations, shouldCache); | ||
} | ||
@@ -974,3 +1006,3 @@ return ret; | ||
if (_this.parent) { | ||
return _this.parent.createAndCacheDependency(id, quantity); | ||
return _this.parent.createDependency(id, quantity, undefined, shouldCache); | ||
} | ||
@@ -1025,3 +1057,3 @@ else { | ||
export { Inject, Injector, LookUp, Many, Optional, Quantity, RediError, Self, SkipSelf, createIdentifier, forwardRef, isAsyncDependencyItem, isAsyncHook, isClassDependencyItem, isCtor, isFactoryDependencyItem, isValueDependencyItem, registerSingleton, setDependencies }; | ||
export { Inject, Injector, LookUp, Many, Optional, Quantity, RediError, Self, SkipSelf, WithNew, createIdentifier, forwardRef, isAsyncDependencyItem, isAsyncHook, isClassDependencyItem, isCtor, isFactoryDependencyItem, isValueDependencyItem, registerSingleton, setDependencies }; | ||
//# sourceMappingURL=redi.js.map |
{ | ||
"$schema": "https://raw.githubusercontent.com/wendellhu95/squirrel/master/src/schema/package.schema.json", | ||
"$schema": "https://raw.githubusercontent.com/hullis/squirrel/master/src/schema/package.schema.json", | ||
"name": "@wendellhu/redi", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "A dependency library for TypeScript and JavaScript, along with a binding for React.", | ||
@@ -19,3 +19,3 @@ "exports": { | ||
}, | ||
"author": "wendellhu95 <hullis@foxmail.com>", | ||
"author": "hullis <hullis@foxmail.com>", | ||
"license": "MIT", | ||
@@ -22,0 +22,0 @@ "peerDependencies": { |
# redi | ||
 | ||
 | ||
 | ||
 | ||
[](https://codecov.io/gh/wendellhu95/redi) | ||
 | ||
[](https://codecov.io/gh/hullis/redi) | ||
@@ -16,4 +16,3 @@ A dependency library for TypeScript and JavaScript, along with a binding for React. | ||
class AuthService { | ||
public getCurrentUserInfo(): UserInfo { | ||
} | ||
public getCurrentUserInfo(): UserInfo {} | ||
} | ||
@@ -38,12 +37,12 @@ | ||
* [Demo TodoMVC](https://wendellhu95.github.io/redi-todomvc/) | [source](https://github.com/wendellhu95/redi-todomvc) | ||
* Doc site [source](https://github.com/wendellhu95/redi-site) | ||
* [scaffold](https://github.com/wendellhu95/redi-starter) | ||
- [Demo TodoMVC](https://hullis.github.io/redi-todomvc/) | [source](https://github.com/hullis/redi-todomvc) | ||
- Doc site [source](https://github.com/hullis/redi-site) | ||
- [scaffold](https://github.com/hullis/redi-starter) | ||
## Users | ||
* Team Lark at ByteDance | ||
- Team Lark at ByteDance | ||
## License | ||
MIT. Copyright 2021 Wendell Hu. | ||
MIT. Copyright 2021-2022 Wendell Hu. |
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
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
418341
81
4215
47