Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Deno.truncateSync

Synchronously truncates or extends the specified file, to reach the specified len. If len is not specified then the entire file contents are truncated.

// truncate the entire file
Deno.truncateSync("my_file.txt");

// truncate part of the file
const file = Deno.makeTempFileSync();
Deno.writeFileSync(file, new TextEncoder().encode("Hello World"));
Deno.truncateSync(file, 7);
const data = Deno.readFileSync(file);
console.log(new TextDecoder().decode(data));

Requires allow-write permission.

function truncateSync(name: string, len?: number): void;
§
truncateSync(name: string, len?: number): void
[src]

§Parameters

§
name: string
[src]
§
len?: number optional
[src]

§Return Type