From dcf391ffed3850f9026d88b146e156375c4619d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 1 May 2023 17:40:00 +0200 Subject: refactor: migrate async ops to generated wrappers (#18937) Migrates some of existing async ops to generated wrappers introduced in https://github.com/denoland/deno/pull/18887. As a result "core.opAsync2" was removed. I will follow up with more PRs that migrate all the async ops to generated wrappers. --- ext/fs/30_fs.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'ext/fs/30_fs.js') diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index 8766d32ff..70cfcee6e 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -1,7 +1,22 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +// deno-lint-ignore-file camelcase + const core = globalThis.Deno.core; const ops = core.ops; +const { + op_chmod_async, + op_ftruncate_async, + op_truncate_async, + op_link_async, + op_flock_async, +} = Deno.core.generateAsyncOpHandler( + "op_chmod_async", + "op_ftruncate_async", + "op_truncate_async", + "op_link_async", + "op_flock_async", +); const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeFilter, @@ -34,7 +49,7 @@ function chmodSync(path, mode) { } async function chmod(path, mode) { - await core.opAsync2("op_chmod_async", pathFromURL(path), mode); + await op_chmod_async(pathFromURL(path), mode); } function chownSync( @@ -347,7 +362,7 @@ function ftruncateSync(rid, len) { } async function ftruncate(rid, len) { - await core.opAsync2("op_ftruncate_async", rid, coerceLen(len)); + await op_ftruncate_async(rid, coerceLen(len)); } function truncateSync(path, len) { @@ -355,7 +370,7 @@ function truncateSync(path, len) { } async function truncate(path, len) { - await core.opAsync2("op_truncate_async", path, coerceLen(len)); + await op_truncate_async(path, coerceLen(len)); } function umask(mask) { @@ -367,7 +382,7 @@ function linkSync(oldpath, newpath) { } async function link(oldpath, newpath) { - await core.opAsync2("op_link_async", oldpath, newpath); + await op_link_async(oldpath, newpath); } function toUnixTimeFromEpoch(value) { @@ -497,7 +512,7 @@ function flockSync(rid, exclusive) { } async function flock(rid, exclusive) { - await core.opAsync2("op_flock_async", rid, exclusive === true); + await op_flock_async(rid, exclusive === true); } function funlockSync(rid) { -- cgit v1.2.3