From 616354e76cba0be8af20a0ffefeacfcf6101bafc Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Wed, 22 Nov 2023 22:11:20 +1100 Subject: refactor: replace `deferred()` from `std/async` with `Promise.withResolvers()` (#21234) Closes #21041 --------- Signed-off-by: Asher Gomez --- tools/util.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tools') 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) { -- cgit v1.2.3