From 5115e82454dda4df1d0b44fcbf3206eac36e9cb2 Mon Sep 17 00:00:00 2001 From: sabio Date: Mon, 15 Jul 2024 13:10:11 +0300 Subject: [PATCH] Simplify array reduce with flatMap 98a9d7b880bf33f8cc7b4a3c7c963ae26f190ebd Pull Request resolved: https://github.com/yandex/metrica-tag/pull/15 --- scripts/genFeatures.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/genFeatures.ts b/scripts/genFeatures.ts index d772e71..f40d714 100644 --- a/scripts/genFeatures.ts +++ b/scripts/genFeatures.ts @@ -108,7 +108,7 @@ const run = async () => { fs.mkdir(GEN_DIR, { recursive: true }); const allFeatures: FeatureType[] = files - .map((filePath) => + .flatMap((filePath) => readAsJSON(filePath).map((feature) => { return { weight: 0, @@ -117,9 +117,6 @@ const run = async () => { } as FeatureType; }), ) - .reduce((carry: FeatureType[], features: FeatureType[]) => { - return carry.concat(features); - }, []) .sort((a, b) => a.weight - b.weight); await Promise.all([