Skip to content

Commit

Permalink
refactor(versioning/distro): Move date handling into distro.ts
Browse files Browse the repository at this point in the history
 - convert a while to a for loop
  • Loading branch information
Gabriel-Ladzaretti committed May 2, 2022
1 parent 7b1a667 commit 0bea310
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/modules/versioning/distro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ export class DistroInfo {
public getNLatest(n: number): DistroInfoRecordWithVersion | null {
const len = this._sortedInfo.length - 1;
let i = len - Math.floor(n);
let j = 0;

while (!this.isReleased(this._sortedInfo[len - j].version)) {
j++;
// adjust i to the latest release
for (let j = len; j >= 0; j--, i--) {
if (this.isReleased(this._sortedInfo[j].version)) {
break;
}
}

i -= j;

if (len >= i && i >= 0 && this.isReleased(this._sortedInfo[i]?.version)) {
return this._sortedInfo[i];
}
Expand Down

0 comments on commit 0bea310

Please sign in to comment.