Deno.truncate
Усекает (или расширяет) указанный файл до указанного len. Если len не указано, содержимое всего файла усекается.
Усечение всего файла
await Deno.truncate("my_file.txt");
Усечение части файла
const file = await Deno.makeTempFile();
await Deno.writeFile(file, new TextEncoder().encode("Hello World"));
await Deno.truncate(file, 7);
const data = await Deno.readFile(file);
console.log(new TextDecoder().decode(data)); // "Hello W"
Требует разрешения allow-write.
function truncate(name: string, len?: number): Promise<void>;
truncate(name: string, len?: number): Promise<void>Параметры
name: stringlen?: number optionalТип возвращаемого значения
Promise<void>
© 2018–2022 the Deno authors
https://doc.deno.land/deno/stable/~/Deno.truncate