From 355d720362e0b9da1c9a058d45a9bac0e6c75e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20N=C3=A4sman?= Date: Thu, 25 Feb 2021 14:59:47 +0100 Subject: [PATCH] use Promise.all Signed-off-by: Eric Peterson --- plugins/search-indexer-backend/src/registry.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/search-indexer-backend/src/registry.ts b/plugins/search-indexer-backend/src/registry.ts index 609bb7b30f..1e5363401a 100644 --- a/plugins/search-indexer-backend/src/registry.ts +++ b/plugins/search-indexer-backend/src/registry.ts @@ -69,22 +69,21 @@ export class Registry { } // TODO: But like with coordination, timing, error handling, and what have you. - async execute(): Promise { - return new Promise(resolve => { - Object.keys(this.collators).forEach(async type => { + async execute() { + return Promise.all( + Object.keys(this.collators).map(async type => { const decorators: IndexableDocumentDecorator[] = ( this.decorators['*'] || [] ).concat(this.decorators[type] || []); - let documents = await this.collators[type].collate(); + let documents = await this.collators[type].collate(); for (let i = 0; i < decorators.length; i++) { documents = await decorators[i](documents); } // TODO: push documents to a configured search engine. - resolve(undefined); - }); - }); + }), + ); } /**