From 1693f247fe894639d3d5050351cbb7ccc0c1b3e3 Mon Sep 17 00:00:00 2001 From: "Micael Levi L. Cavalcante" Date: Mon, 4 Apr 2022 15:51:33 -0400 Subject: [PATCH] refactor(utils): generate unique id only if needed Rely on JS short circuit on OR operation to generate the uuid v4 only if the factory key was not provided --- lib/utils/create-config-factory.util.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/utils/create-config-factory.util.ts b/lib/utils/create-config-factory.util.ts index 64761640..f28c5f20 100644 --- a/lib/utils/create-config-factory.util.ts +++ b/lib/utils/create-config-factory.util.ts @@ -7,9 +7,8 @@ import { ConfigFactoryKeyHost } from './register-as.util'; export function createConfigProvider( factory: ConfigFactory & ConfigFactoryKeyHost, ): FactoryProvider { - const uniqId = uuid(); return { - provide: factory.KEY || getConfigToken(uniqId), + provide: factory.KEY || getConfigToken(uuid()), useFactory: factory, inject: [], };