truncate
Reduces or extends a file to a given size.
Example
ts
import { SF } from "@duplojs/server-utils";
const cleared = await SF.truncate("/tmp/file.bin", 0);
// cleared: E.Ok | SF.FileSystemLeft<"truncate">
await SF.truncate("/tmp/file.bin", 128);Syntax
typescript
function truncate(
path: string,
size?: number
): Promise<FileSystemLeft<"truncate"> | E.Ok>Parameters
path: path of the file.size: new size in bytes (optional).
Return value
E.Ok: if the operation succeeds.FileSystemLeft<"truncate">: if the operation fails.
See also
writeFile- Writes binary content to a file.
