Skip to content

Commit

Permalink
Merge pull request #1343 from ppkgtmm/reduce-double-loop
Browse files Browse the repository at this point in the history
refactor(@nestjs/swagger) reduce loop in MimetypeContentWrapper
  • Loading branch information
kamilmysliwiec authored Jun 18, 2021
2 parents 67254ec + 8e7f4a2 commit 710dbb8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/services/mimetype-content-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ export class MimetypeContentWrapper {
mimetype: string[],
obj: Record<string, any>
): Record<'content', ContentObject> {
const content = mimetype
.map((item) => ({
[item]: obj
}))
.reduce((a, b) => ({ ...a, ...b }), {});
const content = mimetype.reduce(
(acc, item) => ({ ...acc, [item]: obj }),
{}
);
return { content };
}
}

0 comments on commit 710dbb8

Please sign in to comment.