writeSync - Node documentation
function writeSync

Usage

import { writeSync } from "node:fs";

For detailed information, see the documentation of the asynchronous version of this API: write.

Parameters

fd: number
buffer: ArrayBufferView
optional
offset: number | null = 0
optional
length: number | null = buffer.byteLength - offset
optional
position: number | null = 'null'

Return Type

number

The number of bytes written.

Synchronously writes string to the file referenced by the supplied file descriptor, returning the number of bytes written.

Parameters

fd: number

A file descriptor.

string: string

A string to write.

optional
position: number | null

The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

optional
encoding: BufferEncoding | null

The expected string encoding.

Return Type

number