From f7d3be1a54bd536cb29f0ae6b83e612a77fbcef9 Mon Sep 17 00:00:00 2001 From: Maxim Matyunin Date: Tue, 4 Aug 2020 14:56:14 +0900 Subject: [PATCH] get rid of async_for_each --- src/compiler/preprocess/index.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts index 60609f0275..5b330e6c93 100644 --- a/src/compiler/preprocess/index.ts +++ b/src/compiler/preprocess/index.ts @@ -152,10 +152,12 @@ async function process_style( }; } -async function async_for_each(array, callback) { - for (let index = 0; index < array.length; index++) { - await callback(array[index], index, array); - } +function merge_preprocessors(preprocessors: PreprocessorGroup[]): PreprocessorGroup[] { + return [ + ...preprocessors.map(({ markup }) => ({ markup })), + ...preprocessors.map(({ script }) => ({ script })), + ...preprocessors.map(({ style }) => ({ style })), + ]; } export default async function preprocess( @@ -172,13 +174,9 @@ export default async function preprocess( const order = strictOrder ? preprocessors - : [ - ...preprocessors.map(({ markup }) => ({ markup })), - ...preprocessors.map(({ script }) => ({ script })), - ...preprocessors.map(({ style }) => ({ style })), - ]; + : merge_preprocessors(preprocessors); - await async_for_each(order, async p => { + for (const p of order) { let processed; if (p.markup) { @@ -204,7 +202,7 @@ export default async function preprocess( dependencies.push(...processed.dependencies); } } - }); + } return { // TODO return separated output, in future version where svelte.compile supports it: