Skip to content

Commit a7c1e09

Browse files
committed
refactor: avoid .then().finally()
1 parent 5bb5e1c commit a7c1e09

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

app/composables/useCommandPalettePackageVersions.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ export function useCommandPalettePackageVersions(
2323
if (pendingLoad) return pendingLoad
2424

2525
const requestToken = ++loadToken
26-
const load = fetchAllPackageVersions(resolvedPackageName)
27-
.then(allVersions => {
28-
if (requestToken !== loadToken || toValue(packageName) !== resolvedPackageName) return
26+
27+
async function doLoad(name: string) {
28+
try {
29+
const allVersions = await fetchAllPackageVersions(name)
30+
if (requestToken !== loadToken || toValue(packageName) !== name) return
2931
versions.value = allVersions.map(version => version.version)
30-
})
31-
.finally(() => {
32+
} finally {
3233
if (pendingLoad === load) {
3334
pendingLoad = null
3435
}
35-
})
36+
}
37+
}
3638

39+
const load = doLoad(resolvedPackageName)
3740
pendingLoad = load
3841
return load
3942
}

0 commit comments

Comments
 (0)