Skip to content

Commit

Permalink
update asynchronous process of function
Browse files Browse the repository at this point in the history
  • Loading branch information
KHJcode committed Dec 22, 2021
1 parent 4ca6549 commit b5bf67a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/celebrity-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ export class CelebrityService {
async findMostResembleCelebrityByPhotoId(
photoId: string
): Promise<Celebrity | undefined> {
const celebrities = await this.findAllCelebrities();
const faceData = await this.getFaceDataByPhotoId(photoId);
const [celebrities, faceData] = await Promise.all([
this.findAllCelebrities(),
this.getFaceDataByPhotoId(photoId),
]);
let maxSimilarity = -1;
let currentCelebrity: Celebrity | undefined;
for (const celebrity of celebrities) {
Expand Down

0 comments on commit b5bf67a

Please sign in to comment.