Ende.truncateSync
function ยท requires --allow-write
function Ende.truncateSync(name: string, len?: number): voidSynchronously 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
Ende.truncateSync("my_file.txt");
Truncate part of the file
const file = Ende.makeTempFileSync();
Ende.writeFileSync(file, new TextEncoder().encode("Hello World"));
Ende.truncateSync(file, 7);
const data = Ende.readFileSync(file);
console.log(new TextDecoder().decode(data));
Requires allow-write permission.