Skip to content

Truncate

[<Interface>]
type Truncate =
    abstract member Invoke (path: PathLike, callback: NoParamCallback) : unit
    abstract member Invoke (path: PathLike, len: float option, callback: NoParamCallback) : unit
    abstract member __promisify__ (path: PathLike, ?len: float) : Promise<unit>
AssemblyXantham.Fable.Node

Methods

abstract member Invoke (path: PathLike, callback: NoParamCallback) : unit

Truncates the file. No arguments other than a possible exception are given to the completion callback. A file descriptor can also be passed as the first argument. In this case, fs.ftruncate() is called.

import { truncate } from 'node:fs';
// Assuming that 'path/file.txt' is a regular file.
truncate('path/file.txt', (err) => {
if (err) throw err;
console.log('path/file.txt was truncated');
});

Passing a file descriptor is deprecated and may result in an error being thrown in the future.

See the POSIX truncate(2) documentation for more details. Asynchronous truncate(2) - Truncate a file to a specified length.

Parameter
pathA path to a file. If a URL is provided, it must use the file: protocol.
abstract member Invoke (path: PathLike, len: float option, callback: NoParamCallback) : unit

Truncates the file. No arguments other than a possible exception are given to the completion callback. A file descriptor can also be passed as the first argument. In this case, fs.ftruncate() is called.

import { truncate } from 'node:fs';
// Assuming that 'path/file.txt' is a regular file.
truncate('path/file.txt', (err) => {
if (err) throw err;
console.log('path/file.txt was truncated');
});

Passing a file descriptor is deprecated and may result in an error being thrown in the future.

See the POSIX truncate(2) documentation for more details. Asynchronous truncate(2) - Truncate a file to a specified length.

@since v0.8.6

Parameter
pathA path to a file. If a URL is provided, it must use the file: protocol.
abstract member __promisify__ (path: PathLike, ?len: float) : Promise<unit>

Asynchronous truncate(2) - Truncate a file to a specified length.

Parameter
pathA path to a file. If a URL is provided, it must use the file: protocol.
lenIf not specified, defaults to 0.