diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-24 10:31:52 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 00:31:52 +0100 |
commit | 2f47ec6c3a583c8323a06c386feeaee4fbf75edc (patch) | |
tree | 92511f544d3b8466fb84fa40f3e68163a4e97324 /ext/fs/30_fs.js | |
parent | 947ce41e99637dae4cf46126b8bb2d4107fb9913 (diff) |
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
Diffstat (limited to 'ext/fs/30_fs.js')
-rw-r--r-- | ext/fs/30_fs.js | 20 |
1 files changed, 19 insertions, 1 deletions
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); } |