Skip to content

Commit

Permalink
Simplify array reduce with flatMap
Browse files Browse the repository at this point in the history
98a9d7b880bf33f8cc7b4a3c7c963ae26f190ebd

Pull Request resolved: #15
  • Loading branch information
sabio committed Jul 15, 2024
1 parent b2bcd99 commit 5115e82
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions scripts/genFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const run = async () => {
fs.mkdir(GEN_DIR, { recursive: true });

const allFeatures: FeatureType[] = files
.map((filePath) =>
.flatMap((filePath) =>
readAsJSON<FeatureTypeRaw[]>(filePath).map((feature) => {
return {
weight: 0,
Expand All @@ -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([
Expand Down

0 comments on commit 5115e82

Please sign in to comment.