From b14c24a4086e254ae34bf16036c2d350bcf62977 Mon Sep 17 00:00:00 2001 From: Gerald Baulig Date: Thu, 8 Aug 2024 17:20:11 +0200 Subject: [PATCH] refactor(command-interface): compact solution of how to transform Objects to Map --- src/command-interface/index.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/command-interface/index.ts b/src/command-interface/index.ts index 9c08596..d3d09a8 100644 --- a/src/command-interface/index.ts +++ b/src/command-interface/index.ts @@ -126,15 +126,11 @@ export class CommandInterface implements CommandInterfaceServiceImplementation { }); // check for buffer fields - this.bufferedCollection = new Map(); - if (this.config.get('fieldHandlers:bufferFields')) { - for (let bufferedCollection in this.config.get('fieldHandlers:bufferFields')) { - const buffFields = this.config.get('fieldHandlers:bufferFields'); - this.bufferedCollection.set(bufferedCollection, - buffFields[bufferedCollection]); - } - this.logger.info('Buffered collections are:', this.bufferedCollection); - } + const buffFields = this.config.get('fieldHandlers:bufferFields') ?? {}; + this.bufferedCollection = new Map( + Object.entries(buffFields) + ); + this.logger.info('Buffered collections are:', this.bufferedCollection); } /**