File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ export async function callBeforeAppShutdownHook(
5050 module : Module ,
5151 signal ?: string ,
5252) : Promise < void > {
53- const providers = [ ... module . getNonAliasProviders ( ) ] ;
53+ const providers = module . getNonAliasProviders ( ) ;
5454 const [ _ , { instance : moduleClassInstance } ] = providers . shift ( ) ;
5555 const instances = [ ...module . controllers , ...providers ] ;
5656
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ function callOperator(instances: InstanceWrapper[]): Promise<any>[] {
3939 * @param module The module which will be initialized
4040 */
4141export async function callModuleBootstrapHook ( module : Module ) : Promise < any > {
42- const providers = [ ... module . getNonAliasProviders ( ) ] ;
42+ const providers = module . getNonAliasProviders ( ) ;
4343 // Module (class) instance is the first element of the providers array
4444 // Lifecycle hook has to be called once all classes are properly initialized
4545 const [ _ , { instance : moduleClassInstance } ] = providers . shift ( ) ;
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export async function callAppShutdownHook(
4747 module : Module ,
4848 signal ?: string ,
4949) : Promise < any > {
50- const providers = [ ... module . getNonAliasProviders ( ) ] ;
50+ const providers = module . getNonAliasProviders ( ) ;
5151 // Module (class) instance is the first element of the providers array
5252 // Lifecycle hook has to be called once all classes are properly initialized
5353 const [ _ , { instance : moduleClassInstance } ] = providers . shift ( ) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ function callOperator(instances: InstanceWrapper[]): Promise<any>[] {
3939 * @param module The module which will be initialized
4040 */
4141export async function callModuleDestroyHook ( module : Module ) : Promise < any > {
42- const providers = [ ... module . getNonAliasProviders ( ) ] ;
42+ const providers = module . getNonAliasProviders ( ) ;
4343 // Module (class) instance is the first element of the providers array
4444 // Lifecycle hook has to be called once all classes are properly destroyed
4545 const [ _ , { instance : moduleClassInstance } ] = providers . shift ( ) ;
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ function callOperator(instances: InstanceWrapper[]): Promise<any>[] {
3535 * @param module The module which will be initialized
3636 */
3737export async function callModuleInitHook ( module : Module ) : Promise < void > {
38- const providers = [ ... module . getNonAliasProviders ( ) ] ;
38+ const providers = module . getNonAliasProviders ( ) ;
3939 // Module (class) instance is the first element of the providers array
4040 // Lifecycle hook has to be called once all classes are properly initialized
4141 const [ _ , { instance : moduleClassInstance } ] = providers . shift ( ) ;
Original file line number Diff line number Diff line change @@ -38,12 +38,12 @@ export class InstanceWrapper<T = any> {
3838 public readonly async ?: boolean ;
3939 public readonly host ?: Module ;
4040 public readonly scope ?: Scope = Scope . DEFAULT ;
41+ public readonly isAlias : boolean = false ;
42+
4143 public metatype : Type < T > | Function ;
4244 public inject ?: ( string | symbol | Function | Type < any > ) [ ] ;
4345 public forwardRef ?: boolean ;
4446
45- public isAlias : Boolean = false ;
46-
4747 private readonly values = new WeakMap < ContextId , InstancePerContext < T > > ( ) ;
4848 private readonly [ INSTANCE_METADATA_SYMBOL ] : InstanceMetadataStore = { } ;
4949 private readonly [ INSTANCE_ID_SYMBOL ] : string ;
Original file line number Diff line number Diff line change @@ -473,16 +473,8 @@ export class Module {
473473 return this . _providers . get ( name ) as InstanceWrapper < T > ;
474474 }
475475
476- public getNonAliasProviders ( ) : Map < string , InstanceWrapper < Injectable > > {
477- const result = new Map < string , InstanceWrapper < Injectable > > ( ) ;
478-
479- this . _providers . forEach ( ( wrapper , key ) => {
480- if ( ! wrapper . isAlias ) {
481- result . set ( key , wrapper ) ;
482- }
483- } ) ;
484-
485- return result ;
476+ public getNonAliasProviders ( ) : Array < [ string , InstanceWrapper < Injectable > ] > {
477+ return [ ...this . _providers ] . filter ( ( [ _ , wrapper ] ) => ! wrapper . isAlias ) ;
486478 }
487479
488480 public createModuleReferenceType ( ) : any {
You can’t perform that action at this time.
0 commit comments