Skip to content

UseWriteFile

katanakit-js / useWriteFile

function useWriteFile(
path,
data,
options?
): Promise<FilesystemResult<string>>;

Defined in: infrastructure/filesystem/filesystem.service.ts:231

Writes (or overwrites) a file, creating it when missing.

Parameter Type Description
path string Destination file path.
data string | Uint8Array<ArrayBufferLike> Text or bytes to write.
options? { encoding?: | "utf-8" | "utf8" | "ascii" | "base64" | "base64url" | "hex" | "latin1" | "binary" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le"; flag?: string; mode?: number; } Encoding, mode and flag overrides.
options.encoding? | "utf-8" | "utf8" | "ascii" | "base64" | "base64url" | "hex" | "latin1" | "binary" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" -
options.flag? string -
options.mode? number -

Promise<FilesystemResult<string>>

Safe Result with the written path.

const result = await useWriteFile("logs/app.log", "started\n");