Skip to content

Commit a44427b

Browse files
committed
Use Array#find in a less misleading way
It takes a predicate.
1 parent acd6c8e commit a44427b

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

app/routes/crate/version.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,17 @@ export default Route.extend({
4343
crate
4444
.get('versions')
4545
.then(versions => {
46-
const latestStableVersion = versions.find(version => {
46+
const latestStableVersion = versions.find(version =>
4747
// Find the latest version that is stable AND not-yanked.
48-
if (!isUnstableVersion(version.get('num')) && !version.get('yanked')) {
49-
return version;
50-
}
51-
});
48+
!isUnstableVersion(version.get('num')) && !version.get('yanked'));
5249

5350
if (latestStableVersion == null) {
5451
// Cannot find any version that is stable AND not-yanked.
5552
// The fact that "maxVersion" itself cannot be found means that
5653
// we have to fall back to the latest one that is unstable....
57-
const latestUnyankedVersion = versions.find(version => {
54+
const latestUnyankedVersion = versions.find(version =>
5855
// Find the latest version that is not-yanked.
59-
if (!version.get('yanked')) {
60-
return version;
61-
}
62-
});
56+
!version.get('yanked'));
6357

6458
if (latestUnyankedVersion == null) {
6559
// There's not even any unyanked version...

0 commit comments

Comments
 (0)