I don't understand this issue. Cannot one itself use iterate on its code? Is this issue meaning to use iterate in the core code of nest?
@alexjoverm fe:
from: instance-loader.ts
private callModuleInitHook(module: Module) {
const components = [...module.routes, ...module.components];
components.map(([key, {instance}]) => instance)
.filter((instance) => !isNil(instance))
.filter(this.hasOnModuleInitHook)
.forEach((instance) => (instance as OnModuleInit).onModuleInit());
}
Depends on how many components are, this chain will be executed 4 times for N items.
So when we will use iterare:
private callModuleInitHook(module: Module) {
const components = [...module.routes, ...module.components];
iterate(components).map(([key, {instance}]) => instance)
.filter((instance) => !isNil(instance))
.filter(this.hasOnModuleInitHook)
.forEach((instance) => (instance as OnModuleInit).onModuleInit());
}
Will only loop just once for N items. Slightly performance improvements. Bechmarks http://iterare.surge.sh/#performance shows the impact.
Regards.
Hi @cojack,
Since 2.0.0 iterate library is used. Thanks for your proposal :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@alexjoverm fe:
from: instance-loader.ts
Depends on how many components are, this chain will be executed 4 times for N items.
So when we will use iterare:
Will only loop just once for N items. Slightly performance improvements. Bechmarks http://iterare.surge.sh/#performance shows the impact.
Regards.