Skip to content

Commit

Permalink
Code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
yayuyokitano authored Nov 24, 2020
1 parent f9e7109 commit f1ea0a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/classes/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class HelperClass {
let request = [
this.lastfm.user.getTopArtists(user1, {limit, period}),
this.lastfm.user.getTopArtists(user2, {limit, period})
]
];

const res = await Promise.all(request);

Expand Down Expand Up @@ -262,18 +262,20 @@ export default class HelperClass {
let common = [];

while (i1 < aSort.length && i2 < bSort.length) {
if (aSort[i1].name.localeCompare(bSort[i2].name) === 0) {

const compare = aSort[i1].name.localeCompare(bSort[i2].name);

if (compare === 0) {
common.push({
name: aSort[i1].name,
url: aSort[i1].url,
playcount: [parseInt(aSort[i1].playcount), parseInt(bSort[i2].playcount)]
});
i1++;
i2++;
} else if (aSort[i1].name.localeCompare(bSort[i2].name) < 0) {
i1++;
} else {
i2++;
i1 += +(compare < 0);
i2 += +(compare > 0);
}
}
return common;
Expand Down

0 comments on commit f1ea0a5

Please sign in to comment.