Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/levo/templates/new-project/lib/lib.deno_runtime.d.ts>Deno.truncateSync

Server side rendering with The Elm Architecture in Deno
Latest
function Deno.truncateSync
import { Deno } from "https://deno.land/x/levo@v0.0.27/templates/new-project/lib/lib.deno_runtime.d.ts";
const { truncateSync } = Deno;

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.

Parameters

name: string
optional
len: number