mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat: FsFile.sync()
and FsFile.syncSync()
(#22017)
This change: 1. Implements `Deno.FsFile.sync()` and `Deno.FsFile.syncSync()`. 2. Deprecates `Deno.fsync()` and `Deno.fsyncSync()` for removal in Deno v2, in favour of the above corresponding methods. Related #21995 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
2f47ec6c3a
commit
47620641e7
5 changed files with 100 additions and 3 deletions
42
cli/tsc/dts/lib.deno.ns.d.ts
vendored
42
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -2168,6 +2168,9 @@ declare namespace Deno {
|
|||
* console.log(await Deno.readTextFile("my_file.txt")); // H
|
||||
* ```
|
||||
*
|
||||
* @deprecated Use `file.sync()` instead. {@linkcode Deno.fsync} will be
|
||||
* removed in v2.0.0.
|
||||
*
|
||||
* @category I/O
|
||||
*/
|
||||
export function fsync(rid: number): Promise<void>;
|
||||
|
@ -2187,6 +2190,9 @@ declare namespace Deno {
|
|||
* console.log(Deno.readTextFileSync("my_file.txt")); // H
|
||||
* ```
|
||||
*
|
||||
* @deprecated Use `file.syncSync()` instead. {@linkcode Deno.fsyncSync} will
|
||||
* be removed in v2.0.0.
|
||||
*
|
||||
* @category I/O
|
||||
*/
|
||||
export function fsyncSync(rid: number): void;
|
||||
|
@ -2530,6 +2536,42 @@ declare namespace Deno {
|
|||
* ```
|
||||
*/
|
||||
statSync(): FileInfo;
|
||||
/**
|
||||
* Flushes any pending data and metadata operations of the given file
|
||||
* stream to disk.
|
||||
*
|
||||
* ```ts
|
||||
* const file = await Deno.open(
|
||||
* "my_file.txt",
|
||||
* { read: true, write: true, create: true },
|
||||
* );
|
||||
* await file.write(new TextEncoder().encode("Hello World"));
|
||||
* await file.truncate(1);
|
||||
* await file.sync();
|
||||
* console.log(await Deno.readTextFile("my_file.txt")); // H
|
||||
* ```
|
||||
*
|
||||
* @category I/O
|
||||
*/
|
||||
sync(): Promise<void>;
|
||||
/**
|
||||
* Synchronously flushes any pending data and metadata operations of the given
|
||||
* file stream to disk.
|
||||
*
|
||||
* ```ts
|
||||
* const file = Deno.openSync(
|
||||
* "my_file.txt",
|
||||
* { read: true, write: true, create: true },
|
||||
* );
|
||||
* file.writeSync(new TextEncoder().encode("Hello World"));
|
||||
* file.truncateSync(1);
|
||||
* file.syncSync();
|
||||
* console.log(Deno.readTextFileSync("my_file.txt")); // H
|
||||
* ```
|
||||
*
|
||||
* @category I/O
|
||||
*/
|
||||
syncSync(): void;
|
||||
/**
|
||||
* Flushes any pending data operations of the given file stream to disk.
|
||||
* ```ts
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue