mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
feat: stabilize Deno.fsync and Deno.fdatasync (#8038)
This commit is contained in:
parent
070d99645f
commit
dfe19c5c75
4 changed files with 46 additions and 56 deletions
|
@ -47,15 +47,11 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
|||
"connect",
|
||||
"consoleSize",
|
||||
"createHttpClient",
|
||||
"fdatasync",
|
||||
"fdatasyncSync",
|
||||
"formatDiagnostics",
|
||||
"futime",
|
||||
"futimeSync",
|
||||
"fstat",
|
||||
"fstatSync",
|
||||
"fsync",
|
||||
"fsyncSync",
|
||||
"ftruncate",
|
||||
"ftruncateSync",
|
||||
"hostname",
|
||||
|
|
46
cli/dts/lib.deno.ns.d.ts
vendored
46
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -676,6 +676,52 @@ declare namespace Deno {
|
|||
whence: SeekMode,
|
||||
): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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 });
|
||||
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello World"));
|
||||
* Deno.ftruncateSync(file.rid, 1);
|
||||
* Deno.fsyncSync(file.rid);
|
||||
* console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // H
|
||||
* ```
|
||||
*/
|
||||
export function fsyncSync(rid: number): void;
|
||||
|
||||
/**
|
||||
* 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 Deno.write(file.rid, new TextEncoder().encode("Hello World"));
|
||||
* await Deno.ftruncate(file.rid, 1);
|
||||
* await Deno.fsync(file.rid);
|
||||
* console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // H
|
||||
* ```
|
||||
*/
|
||||
export function fsync(rid: number): Promise<void>;
|
||||
|
||||
/*
|
||||
* Synchronously flushes any pending data operations of the given file stream to disk.
|
||||
* ```ts
|
||||
* const file = Deno.openSync("my_file.txt", { read: true, write: true, create: true });
|
||||
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello World"));
|
||||
* Deno.fdatasyncSync(file.rid);
|
||||
* console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // Hello World
|
||||
* ```
|
||||
*/
|
||||
export function fdatasyncSync(rid: number): void;
|
||||
|
||||
/**
|
||||
* Flushes any pending data operations of the given file stream to disk.
|
||||
* ```ts
|
||||
* const file = await Deno.open("my_file.txt", { read: true, write: true, create: true });
|
||||
* await Deno.write(file.rid, new TextEncoder().encode("Hello World"));
|
||||
* await Deno.fdatasync(file.rid);
|
||||
* console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // Hello World
|
||||
* ```
|
||||
*/
|
||||
export function fdatasync(rid: number): Promise<void>;
|
||||
|
||||
/** Close the given resource ID (rid) which has been previously opened, such
|
||||
* as via opening or creating a file. Closing a file when you are finished
|
||||
* with it is important to avoid leaking resources.
|
||||
|
|
46
cli/dts/lib.deno.unstable.d.ts
vendored
46
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -1170,52 +1170,6 @@ declare namespace Deno {
|
|||
*/
|
||||
export function ftruncate(rid: number, len?: number): Promise<void>;
|
||||
|
||||
/* **UNSTABLE**: New API, yet to be vetted.
|
||||
* Synchronously flushes any pending data operations of the given file stream to disk.
|
||||
* ```ts
|
||||
* const file = Deno.openSync("my_file.txt", { read: true, write: true, create: true });
|
||||
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello World"));
|
||||
* Deno.fdatasyncSync(file.rid);
|
||||
* console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // Hello World
|
||||
* ```
|
||||
*/
|
||||
export function fdatasyncSync(rid: number): void;
|
||||
|
||||
/** **UNSTABLE**: New API, yet to be vetted.
|
||||
* Flushes any pending data operations of the given file stream to disk.
|
||||
* ```ts
|
||||
* const file = await Deno.open("my_file.txt", { read: true, write: true, create: true });
|
||||
* await Deno.write(file.rid, new TextEncoder().encode("Hello World"));
|
||||
* await Deno.fdatasync(file.rid);
|
||||
* console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // Hello World
|
||||
* ```
|
||||
*/
|
||||
export function fdatasync(rid: number): Promise<void>;
|
||||
|
||||
/** **UNSTABLE**: New API, yet to be vetted.
|
||||
* 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 });
|
||||
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello World"));
|
||||
* Deno.ftruncateSync(file.rid, 1);
|
||||
* Deno.fsyncSync(file.rid);
|
||||
* console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // H
|
||||
* ```
|
||||
*/
|
||||
export function fsyncSync(rid: number): void;
|
||||
|
||||
/** **UNSTABLE**: New API, yet to be vetted.
|
||||
* 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 Deno.write(file.rid, new TextEncoder().encode("Hello World"));
|
||||
* await Deno.ftruncate(file.rid, 1);
|
||||
* await Deno.fsync(file.rid);
|
||||
* console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // H
|
||||
* ```
|
||||
*/
|
||||
export function fsync(rid: number): Promise<void>;
|
||||
|
||||
/** **UNSTABLE**: New API, yet to be vetted.
|
||||
* Synchronously returns a `Deno.FileInfo` for the given file stream.
|
||||
*
|
||||
|
|
|
@ -282,7 +282,6 @@ fn op_fdatasync_sync(
|
|||
args: Value,
|
||||
_zero_copy: &mut [ZeroCopyBuf],
|
||||
) -> Result<Value, AnyError> {
|
||||
super::check_unstable(state, "Deno.fdatasync");
|
||||
let args: FdatasyncArgs = serde_json::from_value(args)?;
|
||||
let rid = args.rid as u32;
|
||||
std_file_resource(state, rid, |r| match r {
|
||||
|
@ -297,8 +296,6 @@ async fn op_fdatasync_async(
|
|||
args: Value,
|
||||
_zero_copy: BufVec,
|
||||
) -> Result<Value, AnyError> {
|
||||
super::check_unstable2(&state, "Deno.fdatasync");
|
||||
|
||||
let args: FdatasyncArgs = serde_json::from_value(args)?;
|
||||
let rid = args.rid as u32;
|
||||
std_file_resource(&mut state.borrow_mut(), rid, |r| match r {
|
||||
|
@ -319,7 +316,6 @@ fn op_fsync_sync(
|
|||
args: Value,
|
||||
_zero_copy: &mut [ZeroCopyBuf],
|
||||
) -> Result<Value, AnyError> {
|
||||
super::check_unstable(state, "Deno.fsync");
|
||||
let args: FsyncArgs = serde_json::from_value(args)?;
|
||||
let rid = args.rid as u32;
|
||||
std_file_resource(state, rid, |r| match r {
|
||||
|
@ -334,8 +330,6 @@ async fn op_fsync_async(
|
|||
args: Value,
|
||||
_zero_copy: BufVec,
|
||||
) -> Result<Value, AnyError> {
|
||||
super::check_unstable2(&state, "Deno.fsync");
|
||||
|
||||
let args: FsyncArgs = serde_json::from_value(args)?;
|
||||
let rid = args.rid as u32;
|
||||
std_file_resource(&mut state.borrow_mut(), rid, |r| match r {
|
||||
|
|
Loading…
Reference in a new issue