truncateFile
Description
Takes a file descriptor and truncates the file. Resolves the same fileDescriptor if the truncating executed successfully.
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<number || Array> | |
Related Functions | Function Signature | |
function truncateFile(supposedString[, tuple]): Promise<number || Array> |
Examples
1
2
3
4
5
import { truncateFile, openFile } from "puddy-m/lib/fileFunctions";
openFile("./foo.txt", "w")
.then(truncateFile)
.then(console.log); // Possible outcome: 17
1
2
3
4
5
6
7
8
9
import { truncateFile, openFile } from "puddy-m/lib/fileFunctions";
const f = async () => {
const fileDescriptor = await openFile("./foo.txt", "w").then(truncateFile);
console.log(fileDescriptor); // Possible outcome: 17
};
f();