1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

docs: fix ftruncateSync example (#10393)

This commit is contained in:
Yoshiya Hinosawa 2021-04-27 18:23:18 +09:00 committed by GitHub
parent 299518d935
commit 4fa0e9c652
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2357,9 +2357,10 @@ declare namespace Deno {
* Deno.ftruncateSync(file.rid);
*
* // truncate part of the file
* const file = Deno.open("my_file.txt", { read: true, write: true, create: true });
* Deno.write(file.rid, new TextEncoder().encode("Hello World"));
* 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, 7);
* Deno.seekSync(file.rid, 0, Deno.SeekMode.Start);
* const data = new Uint8Array(32);
* Deno.readSync(file.rid, data);
* console.log(new TextDecoder().decode(data)); // Hello W