Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > FileSystem > writeBuffersToFile

FileSystem.writeBuffersToFile() method

Writes the contents of multiple Uint8Arrays to a file on disk, overwriting the file if it already exists. Behind the scenes it uses fs.writevSync().

This API is useful for writing large files efficiently, especially if the input is being concatenated from multiple sources.

Signature:

static writeBuffersToFile(filePath: string, contents: ReadonlyArray<NodeJS.ArrayBufferView>, options?: IFileSystemWriteBinaryFileOptions): void;

Parameters

Parameter

Type

Description

filePath

string

The absolute or relative path of the file.

contents

ReadonlyArray<NodeJS.ArrayBufferView>

The content that should be written to the file.

options

IFileSystemWriteBinaryFileOptions

(Optional) Optional settings that can change the behavior.

Returns:

void

Remarks

Throws an error if the folder doesn't exist, unless ensureFolder=true.