From aaaf16543fe746bf1e483767fb402d86f08e38fc Mon Sep 17 00:00:00 2001 From: sauravniraula Date: Mon, 21 Jul 2025 00:36:24 +0545 Subject: [PATCH] perf(nextjs): evaluates slide element attributes in parallel --- .../nextjs/app/api/presentation_to_pptx_model/route.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/servers/nextjs/app/api/presentation_to_pptx_model/route.ts b/servers/nextjs/app/api/presentation_to_pptx_model/route.ts index f5eceb0c..c39a9c79 100644 --- a/servers/nextjs/app/api/presentation_to_pptx_model/route.ts +++ b/servers/nextjs/app/api/presentation_to_pptx_model/route.ts @@ -159,11 +159,9 @@ async function screenshotElement(element: ElementAttributes, screenshotsDir: str async function getSlidesAttributes(slides: ElementHandle[], screenshotsDir: string): Promise { - const slideAttributes = []; - for (const slide of slides) { - const attributes = await getAllChildElementsAttributes({ element: slide, screenshotsDir }); - slideAttributes.push(attributes); - } + const slideAttributes = await Promise.all( + slides.map((slide) => getAllChildElementsAttributes({ element: slide, screenshotsDir })) + ); return slideAttributes; }