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
await SF.truncate("/tmp/file.bin", 128);Syntax
typescript
function truncate(
path: string | URL,
size?: number
): Promise<FileSystemLeft | E.Ok>Parameters
path: path of the file.size: new size in bytes (optional).
Return value
E.Ok: if the operation succeeds.FileSystemLeft: if the operation fails.
See also
writeFile- Writes binary content to a file.
