diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2023-11-22 22:11:20 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 12:11:20 +0100 |
commit | 616354e76cba0be8af20a0ffefeacfcf6101bafc (patch) | |
tree | c832c81dd93498e196840c8d59c0a4ab76396d07 /tools/util.js | |
parent | 0ffcb46e0f60110c07e21151db6066f5a1b5f710 (diff) |
refactor: replace `deferred()` from `std/async` with `Promise.withResolvers()` (#21234)
Closes #21041
---------
Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Diffstat (limited to 'tools/util.js')
-rw-r--r-- | tools/util.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/tools/util.js b/tools/util.js index 11c07326f..20a2f210b 100644 --- a/tools/util.js +++ b/tools/util.js @@ -1,5 +1,4 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { deferred } from "../test_util/std/async/deferred.ts"; import { dirname, fromFileUrl, @@ -182,10 +181,10 @@ const downloadUrl = export async function downloadPrebuilt(toolName) { // Ensure only one download per tool happens at a time if (DOWNLOAD_TASKS[toolName]) { - return await DOWNLOAD_TASKS[toolName]; + return await DOWNLOAD_TASKS[toolName].promise; } - const downloadPromise = DOWNLOAD_TASKS[toolName] = deferred(); + const downloadDeferred = DOWNLOAD_TASKS[toolName] = Promise.withResolvers(); const spinner = wait({ text: "Downloading prebuilt tool: " + toolName, interval: 1000, @@ -230,12 +229,12 @@ export async function downloadPrebuilt(toolName) { await Deno.rename(tempFile, toolPath); } catch (e) { spinner.fail(); - downloadPromise.reject(e); + downloadDeferred.reject(e); throw e; } spinner.succeed(); - downloadPromise.resolve(null); + downloadDeferred.resolve(null); } export async function verifyVersion(toolName, toolPath) { |