From 2f47ec6c3a583c8323a06c386feeaee4fbf75edc Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Wed, 24 Jan 2024 10:31:52 +1100 Subject: feat: `Deno.FsFile.dataSync()` and `Deno.FsFile.dataSyncSync()` (#22019) This change: 1. Implements `Deno.FsFile.dataSync()` and `Deno.FsFile.dataSyncSync()`. 2. Deprecates `Deno.fdatasync()` and `Deno.fdatasyncSync()` for removal in Deno v2, in favour of the above corresponding methods. 3. Replaces use of `Deno.fdatasync()` and `Deno.fdatasyncSync()` with the above instance methods. Related #21995 --- ext/fs/30_fs.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'ext/fs') diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index 277a1c73c..3c888f1f1 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core, primordials } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { isDate, } = core; @@ -558,10 +558,20 @@ async function symlink( } function fdatasyncSync(rid) { + internals.warnOnDeprecatedApi( + "Deno.fdatasyncSync()", + new Error().stack, + "Use `file.dataSyncSync()` instead.", + ); op_fs_fdatasync_sync(rid); } async function fdatasync(rid) { + internals.warnOnDeprecatedApi( + "Deno.fdatasync()", + new Error().stack, + "Use `await file.dataSync()` instead.", + ); await op_fs_fdatasync_async(rid); } @@ -703,6 +713,14 @@ class FsFile { return fstatSync(this.rid); } + async dataSync() { + await op_fs_fdatasync_async(this.rid); + } + + dataSyncSync() { + op_fs_fdatasync_sync(this.rid); + } + close() { core.close(this.rid); } -- cgit v1.2.3